Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA-Select several ranges using variables
I am trying to develop a dynamic macro that will adjust a given rang
based on several variables. The idea is as follows: ActiveChart.SetSourceData Source:=Sheets("12 15 03 0 KWSC1_1a").Range( _ "C3:C677,E3:E677"), PlotBy:=xlColumns I want to adjust the line of code: "C3:C677,E3:E677" to allow me to us a variable for any reference eg. use variable to reference "C3" i've tried to use cells(row,col) feature but cannot use more than tw instances of cells. thanks -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA-Select several ranges using variables
I am sure there is a better way, but this seems to work
Debug.Print Range(Cells(1, 1).Address & "," & Cells(2, 2).Address & ":" & Cells(3, 3).Address).Address obviously you put you variables in there -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "waveracerr " wrote in message ... I am trying to develop a dynamic macro that will adjust a given range based on several variables. The idea is as follows: ActiveChart.SetSourceData Source:=Sheets("12 15 03 07 KWSC1_1a").Range( _ "C3:C677,E3:E677"), PlotBy:=xlColumns I want to adjust the line of code: "C3:C677,E3:E677" to allow me to use a variable for any reference eg. use variable to reference "C3" i've tried to use cells(row,col) feature but cannot use more than two instances of cells. thanks! --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA-Select several ranges using variables
You could just build/concatenate a string variable that represents th
range. If you know the source columns are in C and E as in your example, an you have some dynamic way of calculating/ determining the start an ending rows, your code could look something like this: Dim intStartRow, intEndRow as Integer Dim strChartRange as String |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
counting ranges with multiple variables | Excel Worksheet Functions | |||
COUNTIF() With multiple ranges and variables | Excel Discussion (Misc queries) | |||
Using variables in Chart Ranges | Charts and Charting in Excel | |||
Cell Variables and Ranges | Excel Discussion (Misc queries) | |||
using variables to set ranges | Excel Programming |