Accessing Arrays stored as a Name

D

dustin.russell

I am currently adapting some old VBA code and want store all my
configuration settings as Names to eliminate having a separate
worksheet for that. I have loaded strings and arrays into names and
have been successful in pulling the strings back out into my code but
when pulling the array back can only access the first value in the
array and cannot find a method to pull specific rows/columns (i.e.
array(2,3)). I have searched online and in VBA books I have and cannot
find anything on this and none of my ideas for making it work have
succeeded so does anyone know if this is even possible?


Dustin Russell
 
T

Tom Ogilvy

Here is one way (demo'd from the immediate window)

v = Evaluate("{11,12,13,14;21,22,23,24;31,32,33,34;41,42,43,44}")
? v(1,1)
11
thisworkbook.Names.Add Name:="ABC", Refersto:=v
v1 = Evaluate(thisworkbook.Names("ABC").Value)
? v1(2,3)
23
 
D

Dustin R

Thanks for the repy, I actually was able to figure out a method by
just declaring an empty array then assigning the names value(s) to it
Dim rptarray() As Variant
rptarray = [reports]
 

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