Hello
I have a workbook that can open a URL into IE when a project number is entered in an input box.
What I would like to happen is that if the project number entered does not have a URL against it and the value is #N/A, then the message box will display "Project does not exist". However if the number does exist, I want a different message box to be displayed which is a yes/no box.
The code below is what I have tried which works fine if the cell value is #N/A but when it is not it throws an Run-Time error 13: Type mismatch
Any help greatly appreciated.
Thanks
Dan
I have a workbook that can open a URL into IE when a project number is entered in an input box.
What I would like to happen is that if the project number entered does not have a URL against it and the value is #N/A, then the message box will display "Project does not exist". However if the number does exist, I want a different message box to be displayed which is a yes/no box.
The code below is what I have tried which works fine if the cell value is #N/A but when it is not it throws an Run-Time error 13: Type mismatch
Code:
Sub SearchPidsMessageBox()
Dim Answer As String
Dim MyNote As String
If CVErr(Range("o2").Value) = CVErr(xlErrNA) Then
MsgBox "PID PR" & Range("n2").Value & " Does not exist", , "Project ID not found"
ElseIf CVErr(Range("o2").Value) <> CVErr(xlErrNA) Then
'Else
'I have tried ElseIF and just Else and both give same error
'Place your text here
MyNote = "PID PR" & Range("n2").Value & " not allocated. Open URL?"
'Display MessageBox
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Project ID Not Found")
If Answer = vbNo Then
'Code for No button Press
Else
'Code for Yes button Press
Call LoadWebPage
End If
End If
End Sub
Any help greatly appreciated.
Thanks
Dan