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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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