MrExcel Publishing
Your One Stop for Excel Tips & Solutions

If statement does not give desired results.

Posted by MILAN on September 24, 2001 9:40 AM

I need this if statement to exit the macro and not go to the VBA editor or
offer the option to debug if the user choosed cancel instead of open in the
file open box.

fileToOpen = Application.GetOpenFilename("text files (*.txt),*.txt")
If fileToOpen <> False Then
MsgBox "Open" & fileToOpen
End If

When cancel is chosen this error message appears.

"Runtime error 1004, False.xls could not be found...."

Posted by dan on September 24, 2001 10:27 AM

How about throwing an
Else Exit Sub

in there, or
If False
Exit Sub