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

I'm having trouble graphing data on a worksheet that has variable ranges.
Can anyone spot the problem with this code? The problem is always with
setting a range for the data.

Here are my variables - I know they work just fine.

xaxis = "A" & "51" & ":" & "A" & 51 + xrange - 1
projected = "D" & "51" & ":" & "D" & 51 + xrange - 1
actual = "E" & "51" & ":" & "E" & 51 + xrange - 1

And here is the first bit of the code for the graph.

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection(1).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(1).Values =
"Sheets(sheetname).Range(projected)"
ActiveChart.SeriesCollection(2).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(2).Values = "Sheets(sheetname).Range(actual)"

"sheetname" is the name of each individual worksheet in the file. That
variable is a string that I've populated earlier in the code.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Graph with variable range

You have put quotes around the range definitions so you are just passing text
instead of ranges. Remove the quotes...

ActiveChart.SeriesCollection(1).XValues = Sheets(sheetname).Range(xaxis)

--
HTH...

Jim Thomlinson


"kcrad" wrote:

I'm having trouble graphing data on a worksheet that has variable ranges.
Can anyone spot the problem with this code? The problem is always with
setting a range for the data.

Here are my variables - I know they work just fine.

xaxis = "A" & "51" & ":" & "A" & 51 + xrange - 1
projected = "D" & "51" & ":" & "D" & 51 + xrange - 1
actual = "E" & "51" & ":" & "E" & 51 + xrange - 1

And here is the first bit of the code for the graph.

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection(1).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(1).Values =
"Sheets(sheetname).Range(projected)"
ActiveChart.SeriesCollection(2).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(2).Values = "Sheets(sheetname).Range(actual)"

"sheetname" is the name of each individual worksheet in the file. That
variable is a string that I've populated earlier in the code.

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Graph with variable range

Sometimes I can be such an idiot!!!

Thanks!

"Jim Thomlinson" wrote:

You have put quotes around the range definitions so you are just passing text
instead of ranges. Remove the quotes...

ActiveChart.SeriesCollection(1).XValues = Sheets(sheetname).Range(xaxis)

--
HTH...

Jim Thomlinson


"kcrad" wrote:

I'm having trouble graphing data on a worksheet that has variable ranges.
Can anyone spot the problem with this code? The problem is always with
setting a range for the data.

Here are my variables - I know they work just fine.

xaxis = "A" & "51" & ":" & "A" & 51 + xrange - 1
projected = "D" & "51" & ":" & "D" & 51 + xrange - 1
actual = "E" & "51" & ":" & "E" & 51 + xrange - 1

And here is the first bit of the code for the graph.

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SeriesCollection(1).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(1).Values =
"Sheets(sheetname).Range(projected)"
ActiveChart.SeriesCollection(2).XValues = "Sheets(sheetname).Range(xaxis)"
ActiveChart.SeriesCollection(2).Values = "Sheets(sheetname).Range(actual)"

"sheetname" is the name of each individual worksheet in the file. That
variable is a string that I've populated earlier in the code.

Thanks!

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
How to graph x-variable versus y-variable in Excel ? Mojjara New Users to Excel 3 April 2nd 09 05:38 PM
VBA to plot graph wiht variable range of data Kok Yong Lee Excel Programming 0 July 12th 06 09:55 AM
Graph with variable data length snoach Excel Discussion (Misc queries) 1 May 27th 05 10:15 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM


All times are GMT +1. The time now is 02:01 PM.

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

About Us

"It's about Microsoft Excel"