Macro for formatting a chart (bar shadows etc.)

GRE800Q

New Member
Joined
Jun 16, 2011
Messages
3
Im tryng to write a macro that always applies the same formatting to the series in my chart, based on what kind of data the series is. For instance, if the series is “Actual” data it should be represented by blue bars with a frame around, if the series is “Year to go” data it should be represented by red bars with a frame around. My macro so far looks like this:
______________________________
Sub Ändra_Bars_Lines()
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Räknare = 0
<o:p></o:p>
Diagramdata = ThisWorkbook.Sheets("DATA_CHART").Range("AI1")

<o:p></o:p>
For Each Cell In Range(Diagramdata)<o:p></o:p>
Räknare = Räknare + 1
<o:p></o:p>
Select Case Cell.Offset(0, -4)
<o:p></o:p>
<o:p></o:p>
Case "ACT"<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Color = RGB(0, 0, 255)<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Border.LineStyle = xlDash
<o:p></o:p>
<o:p></o:p>
Case "YTG"<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Color = RGB(255, 0, 0)<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Border.LineStyle = xlDash
<o:p></o:p>
<o:p></o:p>
Case "PRO"<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Color = RGB(0, 255, 0)
<o:p></o:p>
<o:p></o:p>
Case "BUD"<o:p></o:p>
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Color = RGB(0, 0, 0)
<o:p></o:p>
End Select
<o:p></o:p>
Next
<o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
____________________________________
Now this is all good. What I also want to do (but don’t know how) is:

- Add shadows to the “ACT” and “YTG” bars (equivalent of doing: Format data series – Shadow – Presets – Offset diagonal bottom right)
- Make the “PRO” bars a line with a shadow(equivalent of doing: Change series chart type – Line, Format data series – Shadow – Presets – Offset diagonal bottom right)
- Make the “BUD” bars a dotted line (equivalent of doing: Change series chart type – Line, Format data series – Linestyle – Dash type – Long dash)

When I use the macro recorder it does not record any of those actions. I have tried searching the net for these variables but to no avail.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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