I am having trouble coding a macro in the case where the response to an InputBox request is the "Cancel" button.
As I understand it, the cancel button returns the value "False". The following code results in "Type Mismatch" error 13 at the "If Q = False" line. Q has been defined as a variant. In short, if "Cancel" is clicked, I want he sub to end.
Q = Application.InputBox(Prompt:="Please enter a number from 1 to 3 to indicate how you want the lists sorted:" & vbCr & _
"1 - alphabetically by name;" & vbCr & _
"2 - alphabetically city;" & vbCr & _
"3 - numerically by location number" & vbCr & _
" After number entered, click 'OK.'", Title:="SORT CRITERIA", Type:=1)
' If "cancel" is clicked:
If Q = False Then
ActiveWorkbook.Sheets(sh).Range("D10").Select
Application.CutCopyMode = False
Exit Sub
End If
Other code and the sort routines follow.
Thanks very much for your help.
As I understand it, the cancel button returns the value "False". The following code results in "Type Mismatch" error 13 at the "If Q = False" line. Q has been defined as a variant. In short, if "Cancel" is clicked, I want he sub to end.
Q = Application.InputBox(Prompt:="Please enter a number from 1 to 3 to indicate how you want the lists sorted:" & vbCr & _
"1 - alphabetically by name;" & vbCr & _
"2 - alphabetically city;" & vbCr & _
"3 - numerically by location number" & vbCr & _
" After number entered, click 'OK.'", Title:="SORT CRITERIA", Type:=1)
' If "cancel" is clicked:
If Q = False Then
ActiveWorkbook.Sheets(sh).Range("D10").Select
Application.CutCopyMode = False
Exit Sub
End If
Other code and the sort routines follow.
Thanks very much for your help.