Is it possible to use only variables to reference a range for a chart? The code I have now is pretty long so I'll try to summarize it:
Background: I need a userform that lets the person pick 3 customers and a question and depending on those results create a graph.
The three customers chosen determine the column. Labeled them var1 , var2 , and var3 as string
The question determines the starting and finishing row of data. Labeled them as first and last.
I then recorded a macro of me making the graph that I want and it gave me this:
(There was more code but dealing with the appearance of it)
So I tried to change it to this:
And at the moment I'm receive the error: subscript out of range.
Does anyone have any ideas?
Background: I need a userform that lets the person pick 3 customers and a question and depending on those results create a graph.
The three customers chosen determine the column. Labeled them var1 , var2 , and var3 as string
The question determines the starting and finishing row of data. Labeled them as first and last.
I then recorded a macro of me making the graph that I want and it gave me this:
Code:
ActiveChart.SetSourceData Source:=Sheets("Statistics").Range( _
"B2:B7,C2:C7,D2:D7"), PlotBy:=xlRows
So I tried to change it to this:
Code:
ActiveChart.SetSourceData Source:=Sheets("Statistics").Range(var1 & first & ":" & var1 & last, var2 & first & ":" & var2 & last, var3 & first & ":" & var3 & last), PlotBy:=xlRows
Does anyone have any ideas?