Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Combining Two Ranges

I'm writing code to update a command very similar to

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Range("A1:A21,G1:M21"), PlotBy:=xlRows

except I need to do it using the 'Cells()' format. For
example, instead of using

Range("A1:A21,G1:M21")

since I'm using variables to reference the range, I
believe I need to use the 'Cells()' format instead of
the "A1:.." format. My attempts have looked something
like:

Range((Cells(1, 1), Cells(21, 1), (Cells(1, 7), Cells(10,
7))

This isn't working. Any help is greatly appreciated.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combining Two Ranges

Union(Range(Cells(1, 1), Cells(21, 1)), Range(Cells(1, 7), Cells(10,7)))

--
Regards,
Tom Ogilvy




"SoCalExcel" wrote in message
...
I'm writing code to update a command very similar to

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Range("A1:A21,G1:M21"), PlotBy:=xlRows

except I need to do it using the 'Cells()' format. For
example, instead of using

Range("A1:A21,G1:M21")

since I'm using variables to reference the range, I
believe I need to use the 'Cells()' format instead of
the "A1:.." format. My attempts have looked something
like:

Range((Cells(1, 1), Cells(21, 1), (Cells(1, 7), Cells(10,
7))

This isn't working. Any help is greatly appreciated.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Still not working

I've updated the code to read:

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Union(Range(Cells(1, 1), Cells(PriceBandCounter,
1)), Range(Cells(1, 7), Cells(PriceBandCounter, 7))),
PlotBy:=xlRows

This is returning a Run Time Error 438, Object doesn't
support this property or method...


-----Original Message-----
Union(Range(Cells(1, 1), Cells(21, 1)), Range(Cells(1,

7), Cells(10,7)))

--
Regards,
Tom Ogilvy




"SoCalExcel" wrote

in message
...
I'm writing code to update a command very similar to

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Range("A1:A21,G1:M21"), PlotBy:=xlRows

except I need to do it using the 'Cells()' format. For
example, instead of using

Range("A1:A21,G1:M21")

since I'm using variables to reference the range, I
believe I need to use the 'Cells()' format instead of
the "A1:.." format. My attempts have looked something
like:

Range((Cells(1, 1), Cells(21, 1), (Cells(1, 7), Cells

(10,
7))

This isn't working. Any help is greatly appreciated.

Thanks.



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Still not working

Dim rng as Range
PriceBandCounter = 20

with Worksheets("Graph Data")
set rng = Union(.Range(.Cells(1, 1), .Cells(PriceBandCounter,1)), _
.Range(.Cells(1, 7), .Cells(PriceBandCounter, 7)))
End With

ActiveChart.SetSourceData Source:=rng, _
PlotBy:=xlRows

--
Regards,
Tom Ogilvy

wrote in message
...
I've updated the code to read:

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Union(Range(Cells(1, 1), Cells(PriceBandCounter,
1)), Range(Cells(1, 7), Cells(PriceBandCounter, 7))),
PlotBy:=xlRows

This is returning a Run Time Error 438, Object doesn't
support this property or method...


-----Original Message-----
Union(Range(Cells(1, 1), Cells(21, 1)), Range(Cells(1,

7), Cells(10,7)))

--
Regards,
Tom Ogilvy




"SoCalExcel" wrote

in message
...
I'm writing code to update a command very similar to

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Range("A1:A21,G1:M21"), PlotBy:=xlRows

except I need to do it using the 'Cells()' format. For
example, instead of using

Range("A1:A21,G1:M21")

since I'm using variables to reference the range, I
believe I need to use the 'Cells()' format instead of
the "A1:.." format. My attempts have looked something
like:

Range((Cells(1, 1), Cells(21, 1), (Cells(1, 7), Cells

(10,
7))

This isn't working. Any help is greatly appreciated.

Thanks.



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Thanks!


-----Original Message-----
Dim rng as Range
PriceBandCounter = 20

with Worksheets("Graph Data")
set rng = Union(.Range(.Cells(1, 1), .Cells

(PriceBandCounter,1)), _
.Range(.Cells(1, 7), .Cells(PriceBandCounter, 7)))
End With

ActiveChart.SetSourceData Source:=rng, _
PlotBy:=xlRows

--
Regards,
Tom Ogilvy

wrote in message
...
I've updated the code to read:

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Union(Range(Cells(1, 1), Cells(PriceBandCounter,
1)), Range(Cells(1, 7), Cells(PriceBandCounter, 7))),
PlotBy:=xlRows

This is returning a Run Time Error 438, Object doesn't
support this property or method...


-----Original Message-----
Union(Range(Cells(1, 1), Cells(21, 1)), Range(Cells(1,

7), Cells(10,7)))

--
Regards,
Tom Ogilvy




"SoCalExcel"

wrote
in message
...
I'm writing code to update a command very similar to

ActiveChart.SetSourceData Source:=Sheets("Graph
Data").Range("A1:A21,G1:M21"), PlotBy:=xlRows

except I need to do it using the 'Cells()' format.

For
example, instead of using

Range("A1:A21,G1:M21")

since I'm using variables to reference the range, I
believe I need to use the 'Cells()' format instead

of
the "A1:.." format. My attempts have looked

something
like:

Range((Cells(1, 1), Cells(21, 1), (Cells(1, 7),

Cells
(10,
7))

This isn't working. Any help is greatly

appreciated.

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
combining pivot tables, then making a ranges. HoganD87 Excel Discussion (Misc queries) 1 September 4th 07 07:52 PM
Combining data ranges Karen Excel Worksheet Functions 1 July 10th 07 08:46 PM
Most efficient formula/combining multiple data cell ranges/seperat Tiff New Users to Excel 1 August 2nd 06 04:56 PM
Combining Ranges Luke Bailey Excel Worksheet Functions 1 May 15th 06 10:45 PM
Combining specific ranges from multiple worksheets into one simora Excel Worksheet Functions 0 May 31st 05 12:39 AM


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