Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Specifiy Chart Data Range

I have a data source which varies in length, and I need to specify the data
range for the chart which displays this data. At present I have:
ActiveChart.SetSourceData Source:=Sheets("Site
Data").Range("C2:C500,G2:H500" _
), PlotBy:=xlColumns

Instead of going dwon to line 500 I want it to go down to a line number set
by the variable "lastrow".

Thanks,

Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Specifiy Chart Data Range

Hi Andy,

You could build the address string to include your variable last row number,
or use the Cells method

Dim rSource As Range
Dim lastRow As Long

lastRow = 500

With ActiveWorkbook.Worksheets("Sheet1")
Set rSource = .Range(.Cells(2, 3), .Cells(lastRow, 8))
End With

'Note the dots in the above to qualify cells to the sheet (required if not
on active sheet)

ActiveChart.SetSourceData Source:=rSource, PlotBy:=xlColumns

Regards,
Peter T


"Andy" wrote in message
...
I have a data source which varies in length, and I need to specify the

data
range for the chart which displays this data. At present I have:
ActiveChart.SetSourceData Source:=Sheets("Site
Data").Range("C2:C500,G2:H500" _
), PlotBy:=xlColumns

Instead of going dwon to line 500 I want it to go down to a line number

set
by the variable "lastrow".

Thanks,

Andy



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
Data Validation to range names for Chart Source Data Candyman Charts and Charting in Excel 1 September 3rd 09 07:27 PM
Chart empty with new data in the dynamic range chart. Feejo Excel Discussion (Misc queries) 16 January 3rd 08 10:03 PM
Prob with ChartSource DataData Range MikeZz Charts and Charting in Excel 3 February 6th 07 06:02 PM
Can I use named range in data range box when creating pie chart? BJackson Charts and Charting in Excel 2 August 17th 05 05:37 PM
Specifiy Printer (Location/name) Todd Huttenstine Excel Programming 1 May 5th 04 08:55 PM


All times are GMT +1. The time now is 09:08 PM.

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"