Color visible rows (columns A:R)

sachavez

Active Member
Joined
May 22, 2009
Messages
469
Hi, how can I modify the below code to only color visible rows, but only columns A:R?

With ActiveSheet.UsedRange
.AutoFilter Field:=17, Criteria1:=Array("A", "B", "C", "D", "E"), Operator:=xlFilterValues
.Offset(1).SpecialCells(xlVisible).EntireRow.Interior.Color = 65535
.AutoFilter
End With
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try...

VBA Code:
Dim filteredRange As Range

With ActiveSheet.UsedRange
    .AutoFilter Field:=17, Criteria1:=Array("A", "B", "C", "D", "E"), Operator:=xlFilterValues
    On Error Resume Next
    Set filteredRange = .Offset(1, 0).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    If Not filteredRange Is Nothing Then
        .Offset(1, 0).Resize(.Rows.Count - 1, 18).SpecialCells(xlVisible).Interior.Color = 65535
    End If
    .AutoFilter
End With

Hope this helps!
 
Upvote 1
Try...

VBA Code:
Dim filteredRange As Range

With ActiveSheet.UsedRange
    .AutoFilter Field:=17, Criteria1:=Array("A", "B", "C", "D", "E"), Operator:=xlFilterValues
    On Error Resume Next
    Set filteredRange = .Offset(1, 0).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    If Not filteredRange Is Nothing Then
        .Offset(1, 0).Resize(.Rows.Count - 1, 18).SpecialCells(xlVisible).Interior.Color = 65535
    End If
    .AutoFilter
End With

Hope this helps!
This worked great! Thanks for solving my issue!!!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top