I know there are instances where the Vlookup() will not find a value. When it does not I want it to pop up secondary list. The problem is the Vlookup() errors out when it can't find a value.
Dim iopcert As Variant, hospital As Variant, miss_hosp As String, inp_form As Worksheet
Dim ocd1 As Worksheet, hosp_form As NoOpcert, lngindex As Long
iopcert = Application.InputBox(prompt:="Enter the hospitals opcert #" & i, Title:="OPCERT" & i, Left:=300, Top:=250, Type:=1)
Set ocd1 = ActiveWorkbook.Sheets("OPCERT")
If Len(Application.WorksheetFunction.VLookup(iopcert, ocd1.Range("A1:C187"), 2, False)) = 0 Then
Set hosp_form = NoOpcert
With hosp_form
.Show
miss_hosp = .hosp_list.Value
End With
Unload hosp_form
Set hosp_form = Nothing
If lngindex = -1 Then
MsgBox "Nothing was selected!"
Else
End If
Else
hospital = Application.WorksheetFunction.VLookup(opcert, ocd1.Range("A1:C187"), 2, False)
End If
Any idea how to get around this?
Bookmarks