Can anyone help me please? I’m new to VBA and I’ve written code to run an AutoFilter. It’s only a few lines and I should be able to see what the error is but just cant. It runs and it shows the headings and deletes the rest of the range.
Sub StartEnd()
Dim StDate As Long: StDate = (AO1)
Dim EndDate As Long: EndDate = (AP1)
Set sh = ThisWorkbook.Sheets("sheet1")
sh.AutoFilterMode = False
Range("A1:AN4900").AutoFilter 11, ">=" & StDate ', xlAnd, "<=" & EndDate
End Sub
Sub StartEnd()
Dim StDate As Long: StDate = (AO1)
Dim EndDate As Long: EndDate = (AP1)
Set sh = ThisWorkbook.Sheets("sheet1")
sh.AutoFilterMode = False
Range("A1:AN4900").AutoFilter 11, ">=" & StDate ', xlAnd, "<=" & EndDate
End Sub