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
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,795
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,957
Messages
5,599,051
Members
414,281
Latest member
Engjamal2021

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