ajrob
12-03-2009, 10:22 AM
I'm using Excel 2000 (old school), and am wondering if it is possible to use a variable as a filtering criteria in AutoFilter.
Here's an example of what I wrote, but it doesn't work...
Sub CurrMo_Bookings()
' Applies AutoFilter to DataXfr worksheet for Bookings.
Application.ScreenUpdating = False
' Clears all Filters
Call Clear_DataXfr_Filters
' Filters for Bookings
Dim CurrDate As Integer
CurrDate = InputBox("What is the current date (YYmm)?", "User Input")
Worksheets("DataXfr").Activate
Selection.AutoFilter Field:=23, Criteria1:=CurrDate
Range("B3").Select
End Sub
This is a bit crude, since the MessageBox comes up every time. I was just toying with it to see if I could get the AutoFilter to run properly.
DataXfr is a sheet where I load up all the data from various sheets in the workbook. When I ran the code, it filtered the date field for CurrDate, not 0911 (as would be the case now).
Thanks
Here's an example of what I wrote, but it doesn't work...
Sub CurrMo_Bookings()
' Applies AutoFilter to DataXfr worksheet for Bookings.
Application.ScreenUpdating = False
' Clears all Filters
Call Clear_DataXfr_Filters
' Filters for Bookings
Dim CurrDate As Integer
CurrDate = InputBox("What is the current date (YYmm)?", "User Input")
Worksheets("DataXfr").Activate
Selection.AutoFilter Field:=23, Criteria1:=CurrDate
Range("B3").Select
End Sub
This is a bit crude, since the MessageBox comes up every time. I was just toying with it to see if I could get the AutoFilter to run properly.
DataXfr is a sheet where I load up all the data from various sheets in the workbook. When I ran the code, it filtered the date field for CurrDate, not 0911 (as would be the case now).
Thanks