hi RoyUK,
Many thanks for your response!
I've figured out how to resize the range with your help.
I can't post the table here (data sensitivity), but just to explain this is how the table structure is.
Col A & B: Two levels of Column Headings
Col C onwards: Jan to Dec Data (this depends on which month we are at)
2nd Last Col: Grand total
Last Col: Remarks Col (this is where I apply the filters and format the Data columns accordingly.)
The table starts at Row 3.
The code you posted works without any error... I've another Qn...
How can I filter with more criteria and format the corresponding cells accordingly?
Sub FormatFilteredRows()
Dim ws As Worksheet
Dim uRng As Range
Dim rng As Range
Dim LastRow As Long
Dim MySheets
With Application
.ScreenUpdating = False
.DisplayAlerts = False
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
On Error Resume Next
LastRow = ws.Cells(Rows.Count, 3).End(xlUp)
Set uRng = ws.Cells(4, 3).CurrentRegion
uRng.AutoFilter Field:=16, Criteria1:="=*Reclass*", Operator:=xlOr, Criteria2:="=*Contra*"
Set rng = uRng.Offset(1, 2).Resize(uRng.Rows.Count - 2, _
uRng.Columns.Count - 3)
Set rng = rng.SpecialCells(xlCellTypeVisible)
Set rng = rng.SpecialCells(xlCellTypeConstants, 23)
With rng.Interior
.ColorIndex = 24
.Pattern = xlSolid
End With
' uRng.AutoFilter Field:=16, Criteria1:="=*Pending*"
' Set rng = uRng.Offset(1, 2).Resize(uRng.Rows.Count - 2, _
' uRng.Columns.Count - 3)
' Set rng = rng.SpecialCells(xlCellTypeVisible)
' Set rng = rng.SpecialCells(xlCellTypeConstants, 23)
' With rng.Interior
' .ColorIndex = 34
' .Pattern = xlSolid
' End With
'
' uRng.AutoFilter Field:=16, Criteria1:="=*Completed*"
' Set rng = uRng.Offset(1, 2).Resize(uRng.Rows.Count - 2, _
' uRng.Columns.Count - 3)
' Set rng = rng.SpecialCells(xlCellTypeVisible)
' Set rng = rng.SpecialCells(xlCellTypeConstants, 23)
' With rng.Interior
' .ColorIndex = 40
' .Pattern = xlSolid
' End With
uRng.AutoFilter
On Error GoTo 0
Next
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
Bookmarks