I'm completely new to VBA, and would appreciate some guidance. I would like to use a macro that, on a button press, creates a chart
- Based on the range selected by the user (shown in the image below)
- On a new worksheet
- With x-axis data labels being set to the top row of headings (the blue range)
- With series labels being set according to the three group labels immediately to the left of the data. (the orange range)
So far, all I've succeeded doing is the first one, based on this answer, resulting in the following code:
Sub CommandButton1_Click()
createChart
End Sub
Sub createChart()
Dim myRange As Range
Set myRange = Selection
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=myRange
Cells(1, 1).Select
End Sub
Can anyone advise me how I can change this code to create the chart on a new worksheet, and using the data and series labels in a given range of cells? If need be, I can separate these into different questions. Thank you.

ActiveChart.Location Where:=xlLocationAsObject, Name:="{SheetName}"ActiveChart.Location Where:=xlLocationAsNewSheetis what you want