Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 471
Default Declare Variables in Array

If I wish to dimension this array: DataArray(300,4) and I know this:
1st element of second dimension will be long
2nd element of second dimension will be string
3rd element of second dimension will be integer
4th element of second dimension will be variant (maybe string, maybe long,
etc).
All elements of first dimension would be variant

The way I currently dim this is:
Dim DataArray(300,4) as variant
Can I precisely dimension this array? How? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Declare Variables in Array

Public Type MyUDT
MyLong As Long
MyString As String
MyInteger As Integer
MyVariant As Variant
End Type

Sub Test()
Dim DataArray(1 To 300) As MyUDT
Dim tmp As MyUDT

tmp.MyLong = 33000
tmp.MyString = "Bob"
tmp.MyInteger = 17
tmp.MyVariant = Array(1, 2, 3)
DataArray(1) = tmp

End Sub



--
__________________________________
HTH

Bob

"Mike H." wrote in message
...
If I wish to dimension this array: DataArray(300,4) and I know this:
1st element of second dimension will be long
2nd element of second dimension will be string
3rd element of second dimension will be integer
4th element of second dimension will be variant (maybe string, maybe long,
etc).
All elements of first dimension would be variant

The way I currently dim this is:
Dim DataArray(300,4) as variant
Can I precisely dimension this array? How? Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Declare Variables in Array

or simply

Public Type MyUDT
MyLong As Long
MyString As String
MyInteger As Integer
MyVariant As Variant
End Type

Sub Test()
Dim DataArray(1 To 300) As MyUDT

DataArray(1).MyLong = 33000
DataArray(1).MyString = "Bob"
DataArray(1).MyInteger = 17
DataArray(1).MyVariant = Array(1, 2, 3)

End Sub



--
__________________________________
HTH

Bob

"Mike H." wrote in message
...
If I wish to dimension this array: DataArray(300,4) and I know this:
1st element of second dimension will be long
2nd element of second dimension will be string
3rd element of second dimension will be integer
4th element of second dimension will be variant (maybe string, maybe long,
etc).
All elements of first dimension would be variant

The way I currently dim this is:
Dim DataArray(300,4) as variant
Can I precisely dimension this array? How? Thanks.



Reply
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
Declare and Set Public variables jlclyde Excel Discussion (Misc queries) 2 January 28th 09 02:16 PM
how to declare local variables for Excel.Workbook at runtime. Daffo Excel Discussion (Misc queries) 0 October 9th 06 12:19 PM
How to efficiently declare variables Jeff Excel Discussion (Misc queries) 2 June 29th 06 01:56 PM
How to declare a dynamic array Peter Rooney Excel Discussion (Misc queries) 4 April 13th 05 01:25 PM
How to use array formula for three variables? MelissaS Excel Discussion (Misc queries) 2 January 20th 05 01:16 PM


All times are GMT +1. The time now is 02:09 PM.

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

About Us

"It's about Microsoft Excel"