• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Range in VBA

Krishna20

New Member
Hi,

If I have goven a variable as range does it act as an array?
For example

Dim a as Range
a = Range("A5:Z5").Select

Now if i want to select D5, can this be given a(4) ?

Thank you
 
Krishna

Firstly, Welcome to the Chandoo.org Forums

Your code won't work as it is written

You can do something like:

Code:
Dim a As Range
Set a = Range("A1:Z1")
Debug.Print a(4).Value 'This prints the value of D1  in the Intermediate window

You can then use
Code:
a(4).Select 'This selects the 4th cell in a
to select the 4th element in a
 
Back
Top