How to show error message box when Dropdown selected for month is empty

nitinaw

New Member
Joined
Jun 14, 2013
Messages
1
Please find my code,
Dim IE As Object
Application.DisplayAlerts = False
Dim chromePath As String
Set IE = CreateObject("InternetExplorer.application")
IE.Navigate "https://www.facebook.com/"
IE.Visible = True
Dim doc As Object
IE.Top = 0
IE.Left = 0
IE.Width = 1200
IE.Height = 1000
IE.AddressBar = 0
IE.StatusBar = 0
IE.Toolbar = 0
IE.Visible = True

With IE





Do
If IE.ReadyState = 4 Then
IE.Visible = True
Exit Do
Else
DoEvents
End If
Loop
DoEvents
Application.Wait Now + TimeValue("00:00:05")


IE.Document.getElementById("month").selectedIndex = -2
(As I want to handle this error with some other action so I need to know how can i show the error if nothing gets selected in the dropdown box)
'On Error GoTo Prob
MsgBox "Code has completed"
'Exit Sub





Prob:
MsgBox Err.Description & " has prevented the code completing"

End With
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,216,269
Messages
6,129,813
Members
449,538
Latest member
cookie2956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top