VB: using a string to set a range object?

  • Thread starter Thread starter RGK
  • Start date Start date
R

RGK

I'm a bit new to the excel "range" object type. I was suprised to see that
while I can do:

dim chunk as Range
chunk = .Range(A5:B6)

I apparently cannot do:

dim chunk as Range
dim stuff as string
string = "A5:B6"
chunk= .Range(string)

How can I concatenate up a string describing a range, and then use it to
define a range object's target cells?


- Ross.
 
Oops, I meant chunk = .Range("A5:B6") in the first example - I forgot the
quotes.

R.
 
Objects have to be set.

Variables are referred to by the name not the type.

Dim chunk As Range
Dim stuff As String

stuff = "A5:B6"
Set chunk = Range(stuff)


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top