#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Store array ???

Hello everyone,
I have a small problem: I would like to store an array in VB Excel 2007
(without using a sheet for caching).
You know tell me what instructions can I use so that when strengthened from
the application and return concourse data stored?
There sending code and thank you.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default Store array ???

the only way VBA saves code between execution is using class modules or
userform (which is a class module). Create a class module or userform with
only the array delcared in the module as public. The array doesn't even have
to be in a subroutine or function. Then from your main routine create a new
version of the class module to create the array.

"piero" wrote:

Hello everyone,
I have a small problem: I would like to store an array in VB Excel 2007
(without using a sheet for caching).
You know tell me what instructions can I use so that when strengthened from
the application and return concourse data stored?
There sending code and thank you.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Store array ???



"Joel" wrote:

the only way VBA saves code between execution is using class modules or
userform (which is a class module). Create a class module or userform with
only the array delcared in the module as public. The array doesn't even have
to be in a subroutine or function. Then from your main routine create a new
version of the class module to create the array.


Thank you
If I have understood correctly I just create a class module with the array
declared as public?
If so how do I run the procedure and transfer the data from the standard
module to the class module array?
I am grateful for the cooperation

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9,101
Default Store array ???

In a module put this code

Sub test()

Set ArrayClass = New Class1

For i = ArrayClass.lower To ArrayClass.upper
ArrayClass.WriteArray i, i
Next i

For i = ArrayClass.lower To ArrayClass.upper
msgbox(ArrayClass.ReadArray(i))
Next i


End Sub


Insert a Class module. the first one will be Class1 which is in the above
sub in the New statement. Must be the same

Insert this code into class1module

Dim MyArray As Variant
Public lower As Long
Public upper As Long

Private Sub Class_Initialize()
ReDim MyArray(100)

lower = LBound(MyArray)
upper = UBound(MyArray)
End Sub
Public Sub WriteArray(i, a)

MyArray(i) = a

End Sub
Public Function ReadArray(i)

ReadArray = MyArray(i)

End Function



"piero" wrote:



"Joel" wrote:

the only way VBA saves code between execution is using class modules or
userform (which is a class module). Create a class module or userform with
only the array delcared in the module as public. The array doesn't even have
to be in a subroutine or function. Then from your main routine create a new
version of the class module to create the array.


Thank you
If I have understood correctly I just create a class module with the array
declared as public?
If so how do I run the procedure and transfer the data from the standard
module to the class module array?
I am grateful for the cooperation

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Store array ???

It could be a public variable in a General module.
It could be a static variable in a general module.



Joel wrote:

the only way VBA saves code between execution is using class modules or
userform (which is a class module). Create a class module or userform with
only the array delcared in the module as public. The array doesn't even have
to be in a subroutine or function. Then from your main routine create a new
version of the class module to create the array.

"piero" wrote:

Hello everyone,
I have a small problem: I would like to store an array in VB Excel 2007
(without using a sheet for caching).
You know tell me what instructions can I use so that when strengthened from
the application and return concourse data stored?
There sending code and thank you.


--

Dave Peterson
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
Store cell value and set to zero noyau Excel Discussion (Misc queries) 3 April 10th 08 02:11 PM
Can one store a string in a Array element? [email protected] Excel Discussion (Misc queries) 1 April 17th 07 12:53 PM
store inventory sheet(ex:sports equipment store) vardan Excel Worksheet Functions 1 October 11th 06 12:51 AM
Where to store macros? chin_un_len Excel Discussion (Misc queries) 3 February 11th 06 11:10 PM
Store Functions by a name captain118 Excel Worksheet Functions 1 January 16th 06 03:05 AM


All times are GMT +1. The time now is 06:01 AM.

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"