a string as address in range

pawelch

Registered User.
Local time
Today, 08:05
Joined
Jun 10, 2009
Messages
21
[solved] string as address in range

Dear all

I have been struggling to find an answer to my problem regarding range in vba...

What I want is the following:

Code:
Dim aNames() As String
Dim aAddresses() As Range
...
...
   Do While iIndex < iCounter              
        aNames(iIndex) = ActiveCell.Address
        Set aAddresses(iIndex) = Range(aNames(iIndex))
        iIndex = iIndex + 1
        ActiveCell.Offset(0, 1).Select
   Loop
In other words I am trying to get all addresses of cells within a given range of a row. The problem I come across is how can I use my stored data, because the following does not work:

Code:
" & Range(aAddresses(1).Address).Value & "
Thank you in advance for any help and suggestion!
 
Last edited:
Don't know what you are trying to do but aNames will have the addresses in so

Range(aNames(1)).Value = "afdsa"

will put that in A1 if A1 is the active cell at the start.

Hope that helps.

Oh and I had to define the number of elements in the array.

Brian
 
string as address in range

Hi,

what I was trying to understand why

Code:
" & Range(aAddresses(1).Address).Value & "
did not work and

Code:
" & Range("B2").Value & "
did. Of course I tried:

Code:
& Range(""&aAddresses(1).Address&"").Value &
I was trying to look for an answer to this problem. I have recently found an alternative solution, but thank you anyway for your response.
 

Users who are viewing this thread

Back
Top Bottom