pivot table vba to select all cells containing percentages

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hi Guys, Im creating a macro which highlights a cell based on its value, i have figured it out how to do it for tables, however, I was wondering if there is a way for me to select all the cells which contain percentages and loop through them and conditionally color them?

I have this so far

Code:
Dim cl As Range   Dim pt As PivotTable
    Set pt = ActiveSheet.PivotTables(1)
     Range(pt.PivotFields("KRI").DataRange).Select
    For Each cl In Range(pt.PivotFields("KRI").DataRange)
        If cl <= 0.1 Then
           cl.Interior.Color = 5287936
           cl.Font.ColorIndex = 2
        End If
        Next cl

in this example, i want to color all the cells in green under the column KRI which are less than or equal to 10%, i have the pivot table in tabular form.

any and all help would be greatly appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,216,011
Messages
6,128,269
Members
449,436
Latest member
blaineSpartan

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