How do I get my procedure to exit if cancel is clicked in the InputBox?
So far I have tried
and
Code:
Sub FindTest_Click()
Dim FINDTEST As Variant
Dim TestNameRng As Range
Dim CurrTest As Variant
Set TestNameRng = Range("G7:ProdCodeDesc")
FINDTEST = InputBox(" Enter the name of the test, ***EXACTLY*** as it appears on the data sheet", _
"DELETE TEST", "Enter TEST NAME Here", 6500, 3000)
Application.ScreenUpdating = False
With TestNameRng.Select
Selection.find(What:=FINDTEST, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
Application.ScreenUpdating = True
Set CurrTest = ActiveCell
If MsgBox("Is " & CurrTest & " the correct test to delete from the data sheet", vbYesNo) = vbYes Then
CurrTest.EntireColumn.Delete
Else
Exit Sub
End If
End With
End Sub
So far I have tried
Code:
Dim FINDTEST As Variant
Dim TestNameRng As Range
Dim CurrTest As Variant
Set TestNameRng = Range("G7:ProdCodeDesc")
If FINDTEST = InputBox(" Enter the name of the test, ***EXACTLY*** as it appears on the data sheet", _
"DELETE TEST", "Enter TEST NAME Here", 6500, 3000) = 0 Then
Exit Sub
Else
Application.ScreenUpdating = False
With TestNameRng.Select
Selection.find(What:=FINDTEST, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
Application.ScreenUpdating = True
Set CurrTest = ActiveCell
If MsgBox("Is " & CurrTest & " the correct test to delete from the data sheet", vbYesNo) = vbYes Then
CurrTest.EntireColumn.Delete
Else
Exit Sub
End If
End With
End If
and
Code:
If FINDTEST = InputBox(" Enter the name of the test, ***EXACTLY*** as it appears on the data sheet", _
"DELETE TEST", "Enter TEST NAME Here", 6500, 3000) = False Then
Exit Sub
Else
Application.ScreenUpdating = False