Hi and thanks in advance for any help!
I have a macro that uses auto filter to delete irrelevant rows from a data table. The table is a list of equipment purchases. With each equipment purchase, there is a purchase order number, listed in column A.
Each purchase order number looks like this: "FPyy-####",
so for a purchase made in 2011, the numbers would look like "FP11-9876", "FP11-5432", etc.
and for 2012 the numbers would be "FP12-0001", "FP12-0002", etc...
The macro currently is set to eliminate any orders that don't fall in 2012 (indicated in the VBA with "<>FP12*").
Here is my code:
'Filter for only applicable lines and delete irrelevent data
With ActiveSheet
.AutoFilterMode = False
With Range("A1", Range("L" & Rows.Count).End(xlUp))
.AutoFilter 1, "<>FP12*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
What I'm trying to figure out is if there's a way for the user to indicate what year they want to look at, and then the VBA would auto filter based on that choice.
I'm thinking of a set up where the user would input a four digit year value in a given cell, and then the VBA would somehow look at that cell and then apply that as the auto-filter criteria.
Any thoughts or ideas would be greatly appreciated!
I have a macro that uses auto filter to delete irrelevant rows from a data table. The table is a list of equipment purchases. With each equipment purchase, there is a purchase order number, listed in column A.
Each purchase order number looks like this: "FPyy-####",
so for a purchase made in 2011, the numbers would look like "FP11-9876", "FP11-5432", etc.
and for 2012 the numbers would be "FP12-0001", "FP12-0002", etc...
The macro currently is set to eliminate any orders that don't fall in 2012 (indicated in the VBA with "<>FP12*").
Here is my code:
'Filter for only applicable lines and delete irrelevent data
With ActiveSheet
.AutoFilterMode = False
With Range("A1", Range("L" & Rows.Count).End(xlUp))
.AutoFilter 1, "<>FP12*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
What I'm trying to figure out is if there's a way for the user to indicate what year they want to look at, and then the VBA would auto filter based on that choice.
I'm thinking of a set up where the user would input a four digit year value in a given cell, and then the VBA would somehow look at that cell and then apply that as the auto-filter criteria.
Any thoughts or ideas would be greatly appreciated!