Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
pj pj is offline
external usenet poster
 
Posts: 3
Default charting series

Hi,
I am trying to code a chart series using a program
variable. Selecting the range by hand works ok but that's
a hard-select range. Ie, this works:

Sheets("Chart1").Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Values = "=Query1!
R2C7:R19C7"
ActiveChart.SeriesCollection(3).Name = "=""25% Value"""
ActiveChart.SeriesCollection(3).Select
...

As you can see the .Values are hardcoded to R2C7 to R19C7.
I would like to use a variable range that is determined by
the program. I have tried this:

....Values = .Range(.Cells(2, 7), .Cells(c, 7))

where c is computed, but I get a compile error: Invalid or
unqualified reference with the .Cells being highlighted. I
have already dimmed cell as range.

What am I missing here? And is this idea even do-able? TIA
pj
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default charting series

Try the following code
Dim newRange As Range
Dim nSeries As Integer

Set newRange = ActiveWorkbook.Worksheets("Query1") _
.Range("G2").Resize(c -1 , 1)

Sheets("Chart1").Select
ActiveChart.SeriesCollection.NewSeries
nSeries = ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(nSeries).Values = newRange




"pj" wrote:

Hi,
I am trying to code a chart series using a program
variable. Selecting the range by hand works ok but that's
a hard-select range. Ie, this works:

Sheets("Chart1").Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Values = "=Query1!
R2C7:R19C7"
ActiveChart.SeriesCollection(3).Name = "=""25% Value"""
ActiveChart.SeriesCollection(3).Select
...

As you can see the .Values are hardcoded to R2C7 to R19C7.
I would like to use a variable range that is determined by
the program. I have tried this:

....Values = .Range(.Cells(2, 7), .Cells(c, 7))

where c is computed, but I get a compile error: Invalid or
unqualified reference with the .Cells being highlighted. I
have already dimmed cell as range.

What am I missing here? And is this idea even do-able? TIA
pj

  #3   Report Post  
Posted to microsoft.public.excel.programming
pj pj is offline
external usenet poster
 
Posts: 3
Default charting series

That appears to work. I'm not sure why when re-sizing it's
c-1 raather than c but it works. Thanks.
pj

-----Original Message-----
Try the following code
Dim newRange As Range
Dim nSeries As Integer

Set newRange = ActiveWorkbook.Worksheets("Query1") _
.Range("G2").Resize(c -1 , 1)

Sheets("Chart1").Select
ActiveChart.SeriesCollection.NewSeries
nSeries = ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(nSeries).Values = newRange




"pj" wrote:

Hi,
I am trying to code a chart series using a program
variable. Selecting the range by hand works ok but

that's
a hard-select range. Ie, this works:

Sheets("Chart1").Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(3).Values = "=Query1!
R2C7:R19C7"
ActiveChart.SeriesCollection(3).Name = "=""25%

Value"""
ActiveChart.SeriesCollection(3).Select
...

As you can see the .Values are hardcoded to R2C7 to

R19C7.
I would like to use a variable range that is determined

by
the program. I have tried this:

....Values = .Range(.Cells(2, 7), .Cells(c, 7))

where c is computed, but I get a compile error: Invalid

or
unqualified reference with the .Cells being

highlighted. I
have already dimmed cell as range.

What am I missing here? And is this idea even do-able?

TIA
pj

.

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
Charting the Sum of Two, or More, Series of Data MJ Charts and Charting in Excel 6 April 22nd 10 05:06 PM
Help with Charting Data Series MJ Charts and Charting in Excel 3 July 16th 08 02:01 PM
Charting a discontinuous series Branchola Charts and Charting in Excel 1 March 6th 08 02:33 PM
Time-Series Charting asaylor Charts and Charting in Excel 3 July 19th 06 04:12 PM
CHARTING W/INDIRECT SERIES Ronbo Charts and Charting in Excel 3 January 3rd 05 05:17 PM


All times are GMT +1. The time now is 11:32 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"