variable range automation

G

Guest

I have two identical tables side by side and I'm trying to use one line of
code to work for both tables. How do I write a variable range?

My code is as follows:

If intColumns = 0 Then
ActiveChart.SetSourceData Source:=Sheets("cbot").Range("A2:E30"),
PlotBy:= _
xlColumns
Else
ActiveChart.SetSourceData Source:=Sheets("cbot").Range("I2:M30"),
PlotBy:= _
xlColumns
End If
 
T

Tushar Mehta

What do you want to do?

If you have to decide between two tables, you need a decision making
statement and if you want to set a chart range you need a statement to
do that. That's two statements. You could try and check if the IIF
function will work within the SetSourceData. That is one statement to
set the source range and one function which still comes to two
'things' to do.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

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