Using VBA to Apply Colour Scale Conditional Formatting to a Pivot Table

Manuel_Spreadsheet

New Member
Joined
Oct 21, 2017
Messages
10
Hi all -

I've got a pivot table setup that pulls from my workbook's data model. I've got a macro setup on it that allows me to swap out the values field from one of three options. That's working well but I lose my conditional formatting when swapping in a new values field. So, I'd like to include some code at the end of the macro that applies the conditional formatting. Specifically, I'm trying to accomplish the following:
  • Apply a green, yellow, red color scale
  • Apply the color scale only to the values themselves, not the total column or total row
  • Use the following thresholds for the colors: red = 5th percentile, yellow = 50th percentile, green = 95th percentile
Any guidance or sample code to make this happen would be greatly appreciated.

Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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