how to shade a filtered list using code?

dmasvar

New Member
Joined
Nov 17, 2004
Messages
33
hi,

after a user has filtered a list, is there code to have it shade the lis starting from a certain cell and letting it determine what the end cell should be, the bottom right cell dependiog on the what was filtered..?

using code?

is this possible.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi smasvar,

Try this macro:

Sub ColorFilteredRows()
Dim iRow As Long
Dim UpperLeftCell As Range 'the upper left corner of the filtered range
Dim LastRow As Long
Dim LastCol As Integer
Set UpperLeftCell = Range("B2")
LastRow = Cells(65536, UpperLeftCell.Column).End(xlUp).Row
LastCol = Cells(LastRow, 256).End(xlToLeft).Column
For iRow = UpperLeftCell.Row + 1 To LastRow
If Not Rows(iRow).Hidden Then
Range(Cells(iRow, UpperLeftCell.Column), Cells(iRow, LastCol)).Interior.ColorIndex = 6
End If
Next iRow
End Sub

You should set the UpperLeftCell range to the cell at the top left corner of the filtered range (should be in the row containing the filter dropdowns).

This macro assumes that all cells in the filtered range contain data (no empty cells). If you have empty cells, it becomes a bit more involved.

Keep Excelling.

Damon
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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