the code below works fine. However, when a user doesn’t include anything in the InputBox or clicks on the ‘Close’ button or inputs a value which doesn’t exist I want it to display a msgbox stating the reason and delete sheets ‘PreTotal’.
Is there a better way to handle user input? Need some help here on how to go about it. Thank you.
Sub Filterme()
Dim wSheetStart As Worksheet
Dim rFilterHeads As Range
Dim strCriteria As String
Set wSheetStart = ActiveSheet
Set rFilterHeads = Range("M1", Range("M1").End(xlToLeft))
With wSheetStart
.AutoFilterMode = False
rFilterHeads.AutoFilter
strCriteria = InputBox("Enter Date - MMDDYY")
If strCriteria = vbNullString Then Exit Sub
rFilterHeads.AutoFilter Field:=13, Criteria1:="=*" & strCriteria & "*"
End With
Worksheets("PreTotal").UsedRange.Copy
Sheets.Add.Name = "Total"
Worksheets("Total").Range("A1").PasteSpecial
End Sub
Is this what you are trying?
Change
to
FOLLOWUP
Is this what you are trying? Also if you are filtering the range based on Col M (1st Col in the range) then change the line
to
CODE