Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to refer to multiple ranges, but I do not want to refer directly to
the cell address since these change all the time. Instead I want to refer to the cells by using an expression like variable.Address or something like that. Normally when refering to multiple ranges you simply write like this: Range("C5:D9,G9:H16,B14:D18"). However when I try to write like that but using the indirect reference my program does not understand. My code is: ActiveChart.SetSourceData Source:=Sheets("Indata").Range("rng1.Address:rng1. Offset(1, 0).Address, rng2.Address:rng2.Offset(3,0).Address") Please help me on this one!! I have tried everything but I still dont get it !! Please, please help me!! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Stendahl,
You have the right idea, but needed some tweeking. Since rng1 and rng2 are variable ranges in VBA and not a range name in Excel, you need to have them outside the "". Try the following: =Sheets("Indata").Range(rng1.Address & ":" & rng1.Offset(1, 0).Address & "," & rng2.Address & ":" & rng2.Offset(3, 0).Address) Mike "stendahl_jones" wrote: I want to refer to multiple ranges, but I do not want to refer directly to the cell address since these change all the time. Instead I want to refer to the cells by using an expression like variable.Address or something like that. Normally when refering to multiple ranges you simply write like this: Range("C5:D9,G9:H16,B14:D18"). However when I try to write like that but using the indirect reference my program does not understand. My code is: ActiveChart.SetSourceData Source:=Sheets("Indata").Range("rng1.Address:rng1. Offset(1, 0).Address, rng2.Address:rng2.Offset(3,0).Address") Please help me on this one!! I have tried everything but I still dont get it !! Please, please help me!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referring to Ranges in Change-Event Macro? | Excel Discussion (Misc queries) | |||
Referring to named ranges in a macro | Excel Programming | |||
Referring to named ranges | Excel Programming | |||
Totalling by referring to 2 date ranges | Excel Discussion (Misc queries) | |||
Totalling by referring to 2 date ranges | Excel Discussion (Misc queries) |