0
votes

I am trying to make a macro that creates a chart from three selected columns. It works fine but I am trying to make column 1 (A:A) always apart of the range and then just select the remaining to columns I need as there are multiple charts i need to make from a data sheet

Sub Charter()

    Dim my_range    As Range

    Set my_range = ("A:A", Selection)
    ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
    ActiveChart.FullSeriesCollection(1).ChartType = xlColumnClustered
    ActiveChart.FullSeriesCollection(1).AxisGroup = 1
    ActiveChart.FullSeriesCollection(2).ChartType = xlLine
    ActiveChart.FullSeriesCollection(2).AxisGroup = 1
    ActiveChart.FullSeriesCollection(1).ChartType = xlXYScatter
    ActiveChart.FullSeriesCollection(1).AxisGroup = 1
    ActiveChart.SetSourceData Source:=my_range

    Cells(1, 1).Select

End Sub

I get an

"Compile error: Syntax error"

at the Set my_range = ("A:A", Selection)

1
Have you tried Set my_range = ActiveSheet.Range("A:A") ? - braX
That works to get "A:A" but I still need the range to include Selection - Zacchini
Does this answer your question? Setting Selection as Range - braX

1 Answers

0
votes

Perhaps use Union:

Set my_range = Union(Selection, ActiveSheet.Range("A:A"))