I have the following macro that works fine when the requested Input is supplied.
However, if you hit "Cancel" or just don't input anything, an error message is displayed along with the Message Box stating that "No Recipe # Chosen":
"Run-time error '91': Object variable or With block variable not set"
I want the macro to stop if no Input is given or if the user hits Cancel. What can I add or change to make this happen?
Here's the code:
Dim inputRange As Range
On Error Resume Next
Set inputRange = Application.InputBox("Click cell with Recipe # you want to delete.", "Choose Recipe #", Type:=8)
On Error GoTo 0
If Nothing Is inputRange Then
MsgBox "No Recipe # Chosen."
Else
MsgBox "Recipe " & inputRange.Value & " was chosen."
End If
inputRange.Offset(0, 1).Range("A1:C1").Select
Selection.ClearContents
inputRange.Offset(3, 0).Range("A1:C16").Select
Selection.ClearContents
inputRange.Offset(21, 3).Range("A1:A2").Select
Selection.ClearContents
inputRange.Offset(21, 4).Range("A1").Select
Selection.ClearContents
inputRange.Offset(1, 5).Range("A1").Select
ActiveCell.FormulaR1C1 = "FALSE"
inputRange.Offset(2, 5).Range("A1").Select
ActiveCell.FormulaR1C1 = "FALSE"
inputRange.Offset(3, 5).Range("A1").Select
ActiveCell.FormulaR1C1 = "FALSE"
inputRange.Offset(8, 4).Range("A1").Select
End Sub
Bookmarks