VBA 2-Dimensional Array Unable to Assign Values into Sheet

timotito

New Member
Joined
May 31, 2023
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello, I'm working on a macro which uses a 2-D Variant array to assign some formulas onto an Excel sheet. Here's an MWE:

VBA Code:
Dim aMatrix As Variant
ReDim aMatrix(1 To 15625, 1 To 30)

Dim I As Long
Dim J As Long

For I = 1 To 30
    For J = 1 To 15625
        aMatrix(J, I) = ...
    Next J
Next I

Worksheets("Example").Range("A1:AD15625").Values = aMatrix

After running this macro, I observe that the sheet isn't fully populated; after the 625th row, the sheet is empty. I initially thought it was a RAM issue, but after running this on different PCs and also using a module of VBA functions I found online (VBA Arrays) to attempt to do the assignment column-by-column, the sheet still appears to only populate up to the 625th row. Any ideas or help would be super helpful...cheers.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This filled range A1:AD15625 for me!
Code:
Sub AAAAA()
Dim aMatrix As Variant
ReDim aMatrix(1 To 15625, 1 To 30)
Dim I As Long
Dim J As Long
For I = 1 To 30
    For J = 1 To 15625
        aMatrix(J, I) = I & J
    Next J
Next I
Worksheets("Sheet2").Cells(1, 1).Resize(UBound(aMatrix, 1), UBound(aMatrix, 2)) = aMatrix
End Sub

BTW, what is an MWE?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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