LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default arrays, name, and UDT woes

I am working with Excel 2002. I have some metadata that i want to store in a spreadsheet. I don't want the data to be exposed to the user. I found some information that lead me to believe that i could store an array in a name but i am not able to make it work the way i expect.

Test 1 -

Dim mydata(
Dim v As Varian

ReDim mydata(1, 1) ' mimic how the actual program will work
mydata(0, 0) = "ForbiddenRange
mydata(0, 1) = "$J$2:$L$98

' Store the array on the worksheet
ActiveWorkbook.ActiveSheet.Names.Add name:="a", RefersTo:=mydat

v = ActiveWorkbook.Names("a"

I expected v(0,0) = "ForbiddenRange" and v(0,1) = "$J$2:$L$98

Trying ?v(0,0) or ?v(0,1) causes a Type Mismatch error. Dumping v by itself i get: ?v ={"ForbiddenRange","$J$2:$L$98";#N/A,#N/A

The only way that I see to work with the data stored in v is as a single string which defeats the purpose of storing it in an array in the first place. How do I get the values back out of the name as an array

Test 2 -

It would be useful to store and retrieve an array of user defined type.

The following code example throws a compiler error at the line which performs RefersTo:data. The error dialog says: "Only user defined types in public object modules can be coerced to or from variant or passed to late bound functions"

This code is in a module and from what i can tell it is public.

Public Type mytes
name As Strin
area As Strin
count As Intege
End Typ

Public v As Varian

Dim data() As mytes

Public Sub tryit(
ReDim data(2

With data(0
.name = "forbidden
.area = "$J$2:$L$98
.count = 1
End Wit

With data(1
.name = "okForYou
.area = "$a$2:$b$98
.count = 2
End Wit

ActiveWorkbook.ActiveSheet.Names.Add name:="b", RefersTo:=dat

Set v = ActiveWorkbook.Names("b") ' trying to evaluate but since the code won't compile we don't get this far
End Su

Can someone tell me what i am missing here (other than possibly a REAL language ;). If this approach doesn't work in Excel can you maybe suggest another way to accomplish my goals here without resorting to writting the metadata to a shadow file or storing it in cells within a sheet

Thank

Mark



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rowliner woes Kim K Excel Discussion (Misc queries) 2 August 4th 06 03:20 PM
HELP: Dir() time-out woes :( ..... KevinGPO Excel Discussion (Misc queries) 2 January 17th 06 01:38 PM
HELP: Dir() time-out woes :( ..... KevinGPO New Users to Excel 2 January 17th 06 01:38 PM
PivotTable woes danison Excel Discussion (Misc queries) 4 December 10th 05 01:10 PM
COUNTIF woes Thermometer Excel Worksheet Functions 6 March 28th 05 02:57 PM


All times are GMT +1. The time now is 04:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"