Same color for same category for stacked column chart and formatting data labels together

naveyafluz

New Member
Joined
Feb 11, 2015
Messages
18
I have been trying for the whole day, but I am not able to solve my problems. Appreciate some excel experts out there who have faced such issue before and found solutions to it.

2024-08-02 20_13_41-Actual Current Loading Chart_Zhenxian - Excel.jpg


As the pic above, I would like my chart to show similar models to be the same color, but I believe it's restricted by Step. For example there is Operator 2 and Operator 3 are working on Mix Model Ion Optic, I would like Mix Model Ion Optic to be in all green instead of 6 different colors. Is it possible?

Also, is possible to change the Data Labels all at once? I can display it all at once, but when I want to change all the labels to show series name, I can only do it one by one.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Select the chart and run the below macro :

VBA Code:
Sub style_chart()

    Dim cht As Chart
    Dim ser As Series

    Set cht = ActiveChart

    With cht

        For i = .SeriesCollection.Count To 1 Step -1
            
            Set ser = .SeriesCollection(i)

            If ser.Name = "7500+ Ion optic" Then
                ser.Format.Fill.ForeColor.RGB = RGB(67, 92, 239)
            ElseIf ser.Name = "Mix Model Ion Optic" Then
                ser.Format.Fill.ForeColor.RGB = RGB(255, 255, 102)
            ElseIf ser.Name = "Q2 7500+" Then
                ser.Format.Fill.ForeColor.RGB = RGB(178, 178, 178)
            ElseIf ser.Name = "Q2 Mix model" Then
                ser.Format.Fill.ForeColor.RGB = RGB(51, 204, 51)
            End If

        Next i
    
    End With

End Sub

1722667970878.png
 
Upvote 0
Solution
Select the chart and run the below macro :

VBA Code:
Sub style_chart()

    Dim cht As Chart
    Dim ser As Series

    Set cht = ActiveChart

    With cht

        For i = .SeriesCollection.Count To 1 Step -1
           
            Set ser = .SeriesCollection(i)

            If ser.Name = "7500+ Ion optic" Then
                ser.Format.Fill.ForeColor.RGB = RGB(67, 92, 239)
            ElseIf ser.Name = "Mix Model Ion Optic" Then
                ser.Format.Fill.ForeColor.RGB = RGB(255, 255, 102)
            ElseIf ser.Name = "Q2 7500+" Then
                ser.Format.Fill.ForeColor.RGB = RGB(178, 178, 178)
            ElseIf ser.Name = "Q2 Mix model" Then
                ser.Format.Fill.ForeColor.RGB = RGB(51, 204, 51)
            End If

        Next i
   
    End With

End Sub

View attachment 114913

It works totally! Thanks for the great help.

Now I only left to solve the Data Labels issue.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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