Hi
I'd like to write some code which will
1) apply an auto-filter to the first row of data that's been put into a sheet (but only if an auto-filter has not already been applied)
2) Checks if the word "Test" is in cell D1
2) If the above is true, then it would filter by the blanks in column D
3) then remove all rows that have a blank value in column D
I'd then like to add an IF statement that says if the word "Test is in cell E1, instead, then it
4) filters by the blanks in column E
5) removes all rows with a blank value in column E.
I've recorded a simple version of the above (without the IF statements) and the code is below - however, this wouldn't work if the raw data applied to the spreadsheet had a greater number of rows.
Does anyone know how to modify the code below so that it applies what is described in points 1 to 5 above? TIA
Sub remove_record()
'remove_record Macro
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$3937").AutoFilter Field:=4, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$U$3935").AutoFilter Field:=4
Range("A1").Select
End Sub
I'd like to write some code which will
1) apply an auto-filter to the first row of data that's been put into a sheet (but only if an auto-filter has not already been applied)
2) Checks if the word "Test" is in cell D1
2) If the above is true, then it would filter by the blanks in column D
3) then remove all rows that have a blank value in column D
I'd then like to add an IF statement that says if the word "Test is in cell E1, instead, then it
4) filters by the blanks in column E
5) removes all rows with a blank value in column E.
I've recorded a simple version of the above (without the IF statements) and the code is below - however, this wouldn't work if the raw data applied to the spreadsheet had a greater number of rows.
Does anyone know how to modify the code below so that it applies what is described in points 1 to 5 above? TIA
Sub remove_record()
'remove_record Macro
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$3937").AutoFilter Field:=4, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$U$3935").AutoFilter Field:=4
Range("A1").Select
End Sub