I want the macro to format cells in the worksheet when the value in column A equals "30", "42" or "7". Below is the code I recorded but since my data changes day to day this will not work. I had a macro in the past that worked with the AutoFilter and it was so much more simpler but I lost it. Any help would be appreciated.
Code
Sub Auto_Filter_Format()
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1").AutoFilter
Range("$A$1:$AA$" & LastRow).AutoFilter Field:=1, Criteria1:=Array( _
"30", "42", "7"), Operator:=xlFilterValues
'How to find first cell in AutoFilter Range? In this case it is cell A5
Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0
.PatternTintAndShade = 0
End With
'How to find first cell in AutoFilter Range? In this case it is cell K5
Range("K5").Select
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveSheet.Range("$A$1:$AA$" & LastRow).AutoFilter Field:=1
End Sub
Display More