Referring to multiple ranges

S

stendahl_jones

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!!
 
C

crazybass2

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top