Forum Discussion

avr1988's avatar
avr1988
Copper Contributor
Apr 21, 2020

Change Backcolor of data bar (pivot) via VBA

Hello,

 

I am looking a while to find, how to change the color of a databar which is in a pivot table. So the data bar should just change the color after clicking the special button.

 

This my code:

Sub Country()

ActiveSheet.PivotTables("PivotTable2").PivotFields("Genre").Orientation = xlHidden

ActiveSheet.PivotTables("PivotTable2").PivotFields("Country").Orientation = xlRowField
ActiveSheet.PivotTables("PivotTable2").PivotFields("Country").Position = 1


Range("E4:E50").Select
Range("E4:E50").Activate

Set myDataBar = Selection.FormatConditions.AddDatabar
With myDataBar.BarColor =

End With

myDataBar.BarFillType = xlDataBarFillSolid

End Sub

Sub Genre()

ActiveSheet.PivotTables("PivotTable2").PivotFields("Country").Orientation = xlHidden

ActiveSheet.PivotTables("PivotTable2").PivotFields("Genre").Orientation = xlRowField
ActiveSheet.PivotTables("PivotTable2").PivotFields("Genre").Position = 1
End Sub

 

Thanks for helping!

No RepliesBe the first to reply

Resources