How to condition format Datafields in Pivot with VBA?

ongharry1014

New Member
Joined
May 11, 2013
Messages
13
I have a Pivot table that looks like below. I need to conditional format just the WOS row to highlight cells that are less than 0 in red, 0.1 to 1.5 in yellow and anything above 1.5 in green. The pivot must keep the formatting when I move the pivot fields around. I have made various attempts on building a code but none of them works.

I wonder if anyone here could help me out with this. Thank you so much!


[TABLE="width: 1051"]
<colgroup><col><col span="3"><col><col span="3"><col><col span="3"><col span="2"></colgroup><tbody>[TR]
[TD][TABLE="width: 1115"]
<colgroup><col><col><col span="3"><col><col span="3"><col><col span="3"><col span="2"></colgroup><tbody>[TR]
[TD]Site Code[/TD]
[TD]Values[/TD]
[TD="align: right"]10/16/2017[/TD]
[TD="align: right"]10/23/2017[/TD]
[TD="align: right"]10/30/2017[/TD]
[TD="align: right"]11/6/2017[/TD]
[TD="align: right"]11/13/2017[/TD]
[TD="align: right"]11/20/2017[/TD]
[TD="align: right"]11/27/2017[/TD]
[TD="align: right"]12/4/2017[/TD]
[TD="align: right"]12/11/2017[/TD]
[TD="align: right"]12/18/2017[/TD]
[TD="align: right"]12/25/2017[/TD]
[TD="align: right"]1/1/2018[/TD]
[TD="align: right"]1/8/2018[/TD]
[/TR]
[TR]
[TD]0875[/TD]
[TD]Forecast [/TD]
[TD="align: right"]2049[/TD]
[TD="align: right"]615[/TD]
[TD="align: right"]406[/TD]
[TD="align: right"]397[/TD]
[TD="align: right"]395[/TD]
[TD="align: right"]415[/TD]
[TD="align: right"]441[/TD]
[TD="align: right"]420[/TD]
[TD="align: right"]427[/TD]
[TD="align: right"]424[/TD]
[TD="align: right"]388[/TD]
[TD="align: right"]369[/TD]
[TD="align: right"]375[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Supply [/TD]
[TD="align: right"]2525[/TD]
[TD="align: right"]1280[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]640[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]640[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]640[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]640[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Cumulative Delta [/TD]
[TD="align: right"]476[/TD]
[TD="align: right"]1141[/TD]
[TD="align: right"]735[/TD]
[TD="align: right"]978[/TD]
[TD="align: right"]583[/TD]
[TD="align: right"]808[/TD]
[TD="align: right"]687[/TD]
[TD="align: right"]587[/TD]
[TD="align: right"]800[/TD]
[TD="align: right"]696[/TD]
[TD="align: right"]628[/TD]
[TD="align: right"]579[/TD]
[TD="align: right"]844[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]WOS [/TD]
[TD="align: right"]1.08[/TD]
[TD="align: right"]2.75[/TD]
[TD="align: right"]1.78[/TD]
[TD="align: right"]2.39[/TD]
[TD="align: right"]1.43[/TD]
[TD="align: right"]2.01[/TD]
[TD="align: right"]1.72[/TD]
[TD="align: right"]1.45[/TD]
[TD="align: right"]1.97[/TD]
[TD="align: right"]1.70[/TD]
[TD="align: right"]1.56[/TD]
[TD="align: right"]1.50[/TD]
[TD="align: right"]2.29[/TD]
[/TR]
[TR]
[TD]0874[/TD]
[TD]Forecast [/TD]
[TD="align: right"]772[/TD]
[TD="align: right"]418[/TD]
[TD="align: right"]418[/TD]
[TD="align: right"]418[/TD]
[TD="align: right"]418[/TD]
[TD="align: right"]446[/TD]
[TD="align: right"]555[/TD]
[TD="align: right"]554[/TD]
[TD="align: right"]555[/TD]
[TD="align: right"]555[/TD]
[TD="align: right"]275[/TD]
[TD="align: right"]274[/TD]
[TD="align: right"]275[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Supply [/TD]
[TD="align: right"]2083[/TD]
[TD="align: right"]256[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]256[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]512[/TD]
[TD="align: right"]256[/TD]
[TD="align: right"]256[/TD]
[TD="align: right"]256[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Cumulative Delta [/TD]
[TD="align: right"]1311[/TD]
[TD="align: right"]1149[/TD]
[TD="align: right"]731[/TD]
[TD="align: right"]825[/TD]
[TD="align: right"]919[/TD]
[TD="align: right"]729[/TD]
[TD="align: right"]686[/TD]
[TD="align: right"]644[/TD]
[TD="align: right"]601[/TD]
[TD="align: right"]558[/TD]
[TD="align: right"]539[/TD]
[TD="align: right"]521[/TD]
[TD="align: right"]502[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]WOS [/TD]
[TD="align: right"]2.77[/TD]
[TD="align: right"]2.35[/TD]
[TD="align: right"]1.55[/TD]
[TD="align: right"]1.82[/TD]
[TD="align: right"]2.11[/TD]
[TD="align: right"]1.76[/TD]
[TD="align: right"]1.79[/TD]
[TD="align: right"]1.81[/TD]
[TD="align: right"]1.83[/TD]
[TD="align: right"]1.86[/TD]
[TD="align: right"]1.76[/TD]
[TD="align: right"]1.68[/TD]
[TD="align: right"]1.60[/TD]
[/TR]
[TR]
[TD]32F2[/TD]
[TD]Forecast [/TD]
[TD="align: right"]2026[/TD]
[TD="align: right"]469[/TD]
[TD="align: right"]256[/TD]
[TD="align: right"]250[/TD]
[TD="align: right"]253[/TD]
[TD="align: right"]247[/TD]
[TD="align: right"]235[/TD]
[TD="align: right"]223[/TD]
[TD="align: right"]229[/TD]
[TD="align: right"]226[/TD]
[TD="align: right"]242[/TD]
[TD="align: right"]230[/TD]
[TD="align: right"]237[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Supply [/TD]
[TD="align: right"]1855[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]1280[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]640[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]320[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Cumulative Delta [/TD]
[TD="align: right"]-171[/TD]
[TD="align: right"]-640[/TD]
[TD="align: right"]-896[/TD]
[TD="align: right"]134[/TD]
[TD="align: right"]-119[/TD]
[TD="align: right"]274[/TD]
[TD="align: right"]359[/TD]
[TD="align: right"]456[/TD]
[TD="align: right"]547[/TD]
[TD="align: right"]321[/TD]
[TD="align: right"]399[/TD]
[TD="align: right"]489[/TD]
[TD="align: right"]572[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]WOS [/TD]
[TD="align: right"]-0.63[/TD]
[TD="align: right"]-2.67[/TD]
[TD="align: right"]-3.76[/TD]
[TD="align: right"]0.57[/TD]
[TD="align: right"]-0.51[/TD]
[TD="align: right"]1.18[/TD]
[TD="align: right"]1.54[/TD]
[TD="align: right"]1.91[/TD]
[TD="align: right"]2.25[/TD]
[TD="align: right"]1.30[/TD]
[TD="align: right"]1.52[/TD]
[TD="align: right"]1.71[/TD]
[TD="align: right"]1.85[/TD]
[/TR]
[TR]
[TD]33SC[/TD]
[TD]Forecast [/TD]
[TD="align: right"]188[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]26[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Supply [/TD]
[TD="align: right"]210[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]160[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]160[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]160[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Cumulative Delta [/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]-17[/TD]
[TD="align: right"]-59[/TD]
[TD="align: right"]60[/TD]
[TD="align: right"]21[/TD]
[TD="align: right"]-19[/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]68[/TD]
[TD="align: right"]37[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]134[/TD]
[TD="align: right"]105[/TD]
[TD="align: right"]79[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]WOS [/TD]
[TD="align: right"]0.58[/TD]
[TD="align: right"]-0.46[/TD]
[TD="align: right"]-1.64[/TD]
[TD="align: right"]1.75[/TD]
[TD="align: right"]0.64[/TD]
[TD="align: right"]-0.61[/TD]
[TD="align: right"]3.46[/TD]
[TD="align: right"]2.50[/TD]
[TD="align: right"]1.46[/TD]
[TD="align: right"]0.25[/TD]
[TD="align: right"]6.20[/TD]
[TD="align: right"]5.28[/TD]
[TD="align: right"]4.55[/TD]
[/TR]
[TR]
[TD]Z201[/TD]
[TD]Forecast [/TD]
[TD="align: right"]1000[/TD]
[TD="align: right"]224[/TD]
[TD="align: right"]110[/TD]
[TD="align: right"]140[/TD]
[TD="align: right"]110[/TD]
[TD="align: right"]139[/TD]
[TD="align: right"]181[/TD]
[TD="align: right"]180[/TD]
[TD="align: right"]181[/TD]
[TD="align: right"]181[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]45[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Supply [/TD]
[TD="align: right"]1104[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]320[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Cumulative Delta [/TD]
[TD="align: right"]104[/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]90[/TD]
[TD="align: right"]270[/TD]
[TD="align: right"]160[/TD]
[TD="align: right"]341[/TD]
[TD="align: right"]160[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]119[/TD]
[TD="align: right"]258[/TD]
[TD="align: right"]213[/TD]
[TD="align: right"]168[/TD]
[TD="align: right"]123[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]WOS [/TD]
[TD="align: right"]0.66[/TD]
[TD="align: right"]1.31[/TD]
[TD="align: right"]0.62[/TD]
[TD="align: right"]2.03[/TD]
[TD="align: right"]1.28[/TD]
[TD="align: right"]3.02[/TD]
[TD="align: right"]1.66[/TD]
[TD="align: right"]3.74[/TD]
[TD="align: right"]1.87[/TD]
[TD="align: right"]5.45[/TD]
[TD="align: right"]4.47[/TD]
[TD="align: right"]3.53[/TD]
[TD="align: right"]2.58[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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