Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jeh jeh is offline
external usenet poster
 
Posts: 6
Default Use of Range(Cell1,Cell2) in chart creation

I'm trying to create charts of various data sets using a calculated
dynamic range. However "SetSourceData Source" seems to be limited in
the types of expression it will allow for ranges. For example:

ActiveChart.SetSourceData Source:=Sheets("One").Range("D5:E29')
is OK, but

ActiveChart.SetSourceData Source:=Sheets("One").Range(Cells(5, 4),
Cells(29, 5)),
tells me that "Method 'Cells' of object '_Global' failed".

I need to be able to use the second technique, or some variant of it.
Could someone please suggest a work-around? (BTW,
Sheets("One").Selection , where the selection has been pre-organised,
also seems to be forbidden by VBA. Pity, that would have been an ideal
solution)

TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Use of Range(Cell1,Cell2) in chart creation

Hi,

You need to fully qualify your objects.
If this code is running whilst the activechart is a chart sheet then
Cells object will fail.

ActiveChart.SetSourceData _
Source:=Sheets("One").Range(Sheets("One").Cells(5, 4), _
Sheets("One").Cells(29, 5))

Cheers
Andy

jeh wrote:
I'm trying to create charts of various data sets using a calculated
dynamic range. However "SetSourceData Source" seems to be limited in
the types of expression it will allow for ranges. For example:

ActiveChart.SetSourceData Source:=Sheets("One").Range("D5:E29')
is OK, but

ActiveChart.SetSourceData Source:=Sheets("One").Range(Cells(5, 4),
Cells(29, 5)),
tells me that "Method 'Cells' of object '_Global' failed".

I need to be able to use the second technique, or some variant of it.
Could someone please suggest a work-around? (BTW,
Sheets("One").Selection , where the selection has been pre-organised,
also seems to be forbidden by VBA. Pity, that would have been an ideal
solution)

TIA


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
jeh jeh is offline
external usenet poster
 
Posts: 6
Default Use of Range(Cell1,Cell2) in chart creation

Thanks Andy.
Cheers
John

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 decrease cell1 value if i increase cell2 value & visaversa apmelectronic Excel Discussion (Misc queries) 6 June 25th 09 03:01 PM
Cell1 must be blank before cell2 can except date Daniel Excel Discussion (Misc queries) 1 May 11th 06 11:36 PM
Is there a function, if cell1=Text then cell2=#? Excel 03 A>B [email protected]> Excel Worksheet Functions 2 July 1st 05 07:24 PM
If Cell1 has something Cell2 is blank? HotRod Excel Programming 8 September 2nd 04 02:26 PM
Chart creation ceiling in Excel 2002 via Chart.Add ? Daniel S. Excel Programming 3 August 21st 03 12:06 AM


All times are GMT +1. The time now is 05:28 AM.

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"