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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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