VBA code to autofilter on activecell with varying cell types: text, number or dates
I need help writing the VBA code to filter on my activecell.
My current code works except when the activecell is a date!
The data I want to filter is basically a database table, however, the column types vary. They may be an amount, a text, a date, etc.
The code appears to work except when it is a date.
The code needs to work regardless of the activecells data type.
Any help would be appreciated.
Current Code
Sub Filter_by_Active_Cell()
Dim ColNum As Integer
ColNum = ActiveCell.Column - (ActiveCell.CurrentRegion.Column - 1)
Selection.AutoFilter Field:=ColNum, Criteria1:=ActiveCell
End Sub