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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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:
L

Legacy 68668

Guest
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,558
Messages
5,832,455
Members
430,136
Latest member
Asir Jefferson

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
Top