hi
I recorded 3 macros so I could see the code for each and hopefully compile something which will filter for all 3, as the standard Excel filter will only allow for 2.
I am trying to filter to only leave rows with a zero, a blank or that are >=30
The code for code for each came up as follows, yet the column is not number 16, so am not sure the Field:=16 is correct. The column is AN, which is number 40, though it would be better if it simply worked on the active column.
The maximum number in the column would be 100, so from blank and zeroes all the way up to 100
The individual codes are as follows:-
I assume the Record Macro function simply determines the number of rows, but this will possibly be problematic in the future as the macro is to be used on any file and there will be varying numbers of rows. I assume the below code would solve this by selecting the column with the active cell.
So how would it all go together where the active cell's column is selected and filtered for the 3 criteria above?
Thanks so much in advance
I recorded 3 macros so I could see the code for each and hopefully compile something which will filter for all 3, as the standard Excel filter will only allow for 2.
I am trying to filter to only leave rows with a zero, a blank or that are >=30
The code for code for each came up as follows, yet the column is not number 16, so am not sure the Field:=16 is correct. The column is AN, which is number 40, though it would be better if it simply worked on the active column.
The maximum number in the column would be 100, so from blank and zeroes all the way up to 100
The individual codes are as follows:-
Code:
[SIZE=1] ActiveSheet.Range("$Y$1:$BS$633").AutoFilter Field:=16, Criteria1:="="[/SIZE]
[SIZE=1] Selection.AutoFilter[/SIZE]
Code:
[SIZE=1] ActiveSheet.Range("$Y$1:$BS$633").AutoFilter Field:=16, Criteria1:="0"[/SIZE]
[SIZE=1] Selection.AutoFilter[/SIZE]
Code:
[SIZE=1]ActiveSheet.Range("$Y$1:$BS$633").AutoFilter Field:=16, Criteria1:=">=30"[/SIZE]
[SIZE=1]Selection.AutoFilter[/SIZE]
I assume the Record Macro function simply determines the number of rows, but this will possibly be problematic in the future as the macro is to be used on any file and there will be varying numbers of rows. I assume the below code would solve this by selecting the column with the active cell.
Code:
ActiveSheet.Columns(ActiveCell.Column).EntireColumn.Select
So how would it all go together where the active cell's column is selected and filtered for the 3 criteria above?
Thanks so much in advance
Last edited: