Using only variables to reference a range

Joined
Oct 19, 2011
Messages
4
Reaction score
0
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:

Code:
ActiveChart.SetSourceData Source:=Sheets("Statistics").Range( _
     "B2:B7,C2:C7,D2:D7"), PlotBy:=xlRows
(There was more code but dealing with the appearance of it)

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
And at the moment I'm receive the error: subscript out of range.
Does anyone have any ideas?
 
Joined
Oct 19, 2011
Messages
4
Reaction score
0
Sorry my latest error message is:
Run time error 450
Wrong number of arguments or invalid property assignment
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top