How to change the background color of the filtered data in a Column

mebro

New Member
Joined
Jul 12, 2018
Messages
12
Hi All,

Help me regarding filter option, If I filter the data in any Column of excel sheet, I want to change filtered cell background color for that filtered values, if this is possible please help me else suggest me the best approach for the same

my intention is, if there is any filter on the column then I want to show that differently.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

In order to achieve what you need ... you will have to use an Event macro ...:wink:

Are you familiar with these macros ???
 
Upvote 0
Hi James, thanks for your response. I have used macros but am unsure what is required here. Can you also tell me why this is happening as I have other formulas that are conditionally formatted according to their value without any problems?
 
Upvote 0
Hi James,

thanks for your quick response, can you please help me with macro code for this.
 
Upvote 0
Hi James,

thanks for your quick response, can you please help me with macro code for this.

No problem ...

Can you quickly describe your sheet ...

are your headers in row 1 ?
how many columns do you use ?
which column is the one used to filter ?

HTH
 
Upvote 0
yes, I have Range table with 4 columns with row 1 as the header. i want to filter column 3
 
Upvote 0
Hello,

In order to change the interior color of the filtered rows ... you could use following:
Code:
Sub AddColorFilteredRows()
Dim wks As Worksheet
Dim rng As Range
Dim rce As Range
Dim lrn As Long
Dim lrf As Long


    Set wks = ActiveSheet


    lrn = Application.WorksheetFunction.CountA(Range(Cells(1, 1), Cells(1000, 1)))
    lrf = wks.Range("A" & Rows.Count).End(xlUp).Row
    
      For Each rce In wks.Range("A2:D" & lrn)
        If rce.Interior.Color <> xlNone Then rce.Interior.Color = xlNone
      Next rce
    
    If lrn = lrf Then MsgBox " No Criteria Selected in Autofilter...": Exit Sub
    
    lrf = wks.Range("A" & Rows.Count).End(xlUp).Row
    Set rng = wks.Range("A2:D" & lrf)
    rng.SpecialCells(xlCellTypeVisible).Interior.Color = vbYellow
    
End Sub

Hope this will help :)
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,814
Members
449,340
Latest member
hpm23

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