Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TRAPPING ERROR (2000 sr 1)

    i have this userform and i would want to trapping error if into range G:H of TABELLA not is present the value, i have used on error but not work!:
    Private Sub CommandButton2_Click()

    If Not Left((Me.txtPart.Value), 2) = "OI" Then
    Me.txtPart.SetFocus
    MsgBox "INSERIRE UNA MATRICOLA NEL FORMATO OIXXXXX", vbCritical

    Me.txtPart.Value = ""
    Me.txtLoc.Value = ""
    Me.txtPart.SetFocus

    Exit Sub
    End If

    If Trim(Me.txtPart.Value) = "" Then
    Me.txtPart.SetFocus
    MsgBox "INSERIRE UNA MATRICOLA!", vbCritical
    Exit Sub
    End If

    TEST_MATR = Me.txtPart.Value

    On Error GoTo ERRORE

    Me.txtLoc.Value = Application.WorksheetFunction.VLookup(TEST_MATR, Worksheets("TABELLA").Range(Worksheets("TABELLA"). Range("G2"), Worksheets("TABELLA").Range("H1500").End(xlUp)), 2, False)

    ERRORE:

    MsgBox "MATRICOLA ERRATA O INESITENTE!", vbCritical

    End Sub

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: TRAPPING ERROR (2000 sr 1)

    One thing I notice is that you should add a:
    Exit sub

    before the line:
    ERRORE:

    So if there is no error, it does not run those lines of code...

    If that is not the problem, what exactly is the problem?

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •