Good day
I am a novice at VBA, and a bit lost. I have recorded a macro to create a scatterplot chart from a template in a worksheet. However, I now need to repeat the process but with a different x-axis data range every time (the y-axis data range remains the same with every subsequent chart).
The data are arranged in columns - thus for the first chart data are located in column F rows 2-49 (x-axis), and column D rows 2-49 (y-axis). For the next chart the data are in the same rows but in column G (x-axis) and column D (y-axis) and so on till the x-axis data range reach column AZ (x-axis) and column D (y-axis).
I would really appreciate some help...
Regards
Brand
Here is the macro I recorded for the first chart:
Sub create_charts()
'
' create_charts Macro
'
' Keyboard Shortcut: Ctrl+t
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ApplyChartTemplate ( _
"C:\Users\Brand\AppData\Roaming\Microsoft\Templates\Charts\mag grafieke met rou data.crtx" _
)
ActiveChart.SeriesCollection(1).Name = "='post natal'!$F$1"
ActiveChart.SeriesCollection(1).XValues = "='post natal'!$F$2:$F$49"
ActiveChart.SeriesCollection(1).Values = "='post natal'!$D$2:$D$49"
ActiveChart.SetElement (msoElementChartTitleCenteredOverlay)
End Sub
Bookmarks