Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA-Change chart range to variable

Dim Rng as Range
Dim strName As Object
Set strName = Worksheets("12 15 03 07 KWSC1_1a").Range("O2")

How can I assign a variable to the range, rather than having the "O2
cell reference? I've seen the following:

Dim Rng as Range
Dim myRange As Object
Set myRange = Worksheets("Sheet1").Range(Cells(1,1).Cells(10,5))

...as a way to use Cells and thus vary the column & row.

How can I set the range to something like:
Range(Cells(1,1))?

Also, how can I make the following code based on variables, already th
intStartRow & intEndRow are based on integer variables. The "C" & "O
indicate columns and I want to be able vary those.

strChartRange = "C" & intStartRow & ":C" & intEndRow & ",O" & _
intStartRow & ":O" & intEndRow

Lastly, is there any way set "Sheet1" as a variable? I have a list o
worksheets and would like to be able to run this code on each workshee
in the list.

Thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA-Change chart range to variable

sSheetName = "something"
Set myRange = Worksheets(sSheetname).Cells(i,j)

----------

sSheetName = "something"
strChartRange = "C" & intStartRow & ":C" & intEndRow & ",O" & _
intStartRow & ":O" & intEndRow

set MyRange = worksheets(sSheetname).Range(strChartRange)

--
Regards,
Tom Ogilvy



"waveracerr " wrote in message
...
Dim Rng as Range
Dim strName As Object
Set strName = Worksheets("12 15 03 07 KWSC1_1a").Range("O2")

How can I assign a variable to the range, rather than having the "O2"
cell reference? I've seen the following:

Dim Rng as Range
Dim myRange As Object
Set myRange = Worksheets("Sheet1").Range(Cells(1,1).Cells(10,5))

..as a way to use Cells and thus vary the column & row.

How can I set the range to something like:
Range(Cells(1,1))?

Also, how can I make the following code based on variables, already the
intStartRow & intEndRow are based on integer variables. The "C" & "O"
indicate columns and I want to be able vary those.

strChartRange = "C" & intStartRow & ":C" & intEndRow & ",O" & _
intStartRow & ":O" & intEndRow

Lastly, is there any way set "Sheet1" as a variable? I have a list of
worksheets and would like to be able to run this code on each worksheet
in the list.

Thanks


---
Message posted from http://www.ExcelForum.com/



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
Change chart range with macro Greg Snidow Charts and Charting in Excel 1 March 27th 09 04:57 PM
A copy of a chart doesn't change when the original has new range Piotr (Peter)[_2_] Charts and Charting in Excel 10 September 8th 08 06:55 PM
Variable Range to be used in a chart Jeff Excel Worksheet Functions 1 February 9th 07 03:22 AM
Variable range chart Nikki Excel Discussion (Misc queries) 4 October 20th 06 08:07 PM
how to change range for dynamic chart in excel 2000 with button? ivan Charts and Charting in Excel 2 April 24th 05 04:10 AM


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