Truncation of stored data array

jfklbj

Board Regular
Joined
Feb 9, 2009
Messages
68
I have arrays that I store with the following type statement:

Names.Add name:="StoredUnits", RefersTo:=TotalUnits

Later, when I need the data I recall the array like this:

TotalUnits = [StoredUnits]

The only problem is that the data truncates at 256 array items. Is there any practical way around this without writing to a worksheet?

TIA
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
What are you storing in the array and how are you using it? You can store values in array variables:

Code:
Sub Foo()
'//array with 65536 elements
Dim x() As Variant
For y = 0 To 65535
    ReDim Preserve x(0 To y)
    x(y) = y
Next y
End Sub
 
Last edited:
Upvote 0
I have arrays that I store with the following type statement:

Names.Add name:="StoredUnits", RefersTo:=TotalUnits

Later, when I need the data I recall the array like this:

TotalUnits = [StoredUnits]

The only problem is that the data truncates at 256 array items. Is there any practical way around this without writing to a worksheet?

TIA
If you have random elements and such like more than 30, writing the code for that without using Excel sheet is not practical.

If you have elements already in the range, you could write like
Code:
Dim myArray
myArray = Sheets("Sheet1").Range("a1:a10000").Value
No loop required.
But, it will be always a 1 Based 2D array, so you will need to loop like
Code:
For i = 1 To UBound(myArray, 1)
    MsgBox myArray(i, 1)
Next
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top