Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default variable range automation

I have two identical tables side by side and I'm trying to use one line of
code to create a chart 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

--
Ryan Proudfit
  #2   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default variable range automation

Create a dynamic range name to use as your chart source

Dynamic ranges are described in the following support article.
http://support.microsoft.com/default...b;en-us;830287

then refer to the range name in your code:
ie: instead of using Range("A2:E30"),

you can use Range("DataSource") assuming my named range
is called DataSource


"Ryan Proudfit" wrote:

I have two identical tables side by side and I'm trying to use one line of
code to create a chart 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

--
Ryan Proudfit

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation of change of data range KIOhio Charts and Charting in Excel 4 June 30th 09 04:55 AM
variable range automation Ryan Proudfit Charts and Charting in Excel 1 March 31st 05 01:46 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"