Conditional Formatting to the Pivot Field instead of Selecting Cells

Skuridi

New Member
Joined
Feb 20, 2015
Messages
1
I'm trying to apply a formatting condition to a pivot field, the script below does that but applies Formatting to "Selected Cells" of the Pivot Filed and makes it a static cells range, instead of Pivot Field Values of the pivot table, where as the same can be done manually.
Rich (BB code):
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">ActiveSheet.PivotTables(PivotName).PivotFields("SPEC").DataRange.FormatConditions.Add Type:=xlNoBlanksCondition
With ActiveSheet.PivotTables(PivotName).PivotFields("CPR SPEC").DataRange.FormatConditions(1)
    With.Borders(xlTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .Color = vbBlack
    EndWith
    With.Borders(xlLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .Color = vbBlack
    EndWith
    With.Borders(xlRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .Color = vbBlack
    EndWith
    With.Borders(xlBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .Color = vbBlack
    EndWith
Endwith
</code>
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,215,143
Messages
6,123,277
Members
449,093
Latest member
Vincent Khandagale

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