ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessing Arrays stored as a Name (https://www.excelbanter.com/excel-programming/388688-accessing-arrays-stored-name.html)

[email protected]

Accessing Arrays stored as a Name
 
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


Tom Ogilvy

Accessing Arrays stored as a Name
 
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

--
Regards,
Tom Ogilvy

" wrote:

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



Dustin R

Accessing Arrays stored as a Name
 
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]



All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com