View Single Post
 
Old 06-29-2011, 07:38 AM
QWERTY_Warrior QWERTY_Warrior is offline Windows XP Office 2007
Novice
 
Join Date: Jun 2011
Posts: 1
QWERTY_Warrior is on a distinguished road
Default Macro for chart formating

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()

Räknare = 0
Diagramdata = ThisWorkbook.Sheets("DATA_CHART").Range("AI1")
For Each Cell In Range(Diagramdata)
Räknare = Räknare + 1
Select Case Cell.Offset(0, -4)

Case "ACT"
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Co lor = RGB(0, 0, 255)
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Border.Line Style = xlDash

Case "YTG"
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Co lor = RGB(255, 0, 0)
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Border.Line Style = xlDash

Case "PRO"
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Co lor = RGB(0, 255, 0)

Case "BUD"
Worksheets("CHART").ChartObjects("Chart 1049").Chart.SeriesCollection(Räknare).Interior.Co lor = RGB(0, 0, 0)
End Select
Next
End Sub

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” bar a line, with a shadow, instead of a bar (equivalent of doing: Change series chart type – Line, Format data series – Shadow – Presets – Offset diagonal bottom right)
- Make the “BUD” bar a dotted line instead of a bar (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.
Reply With Quote