![]() |
Referring to multiple ranges
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!! |
Referring to multiple ranges
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!! |
All times are GMT +1. The time now is 12:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com