Subscript out of range after Cell.value call

Copper Contributor

Error happens after macro runs to completion and then is supposed to print data to excel. Macro produces a 10x10 array of values and is sent to the below routine. All the values do print but after completion, a subscript out of range error occurs. Err.description is blank, debug does not highlight any code, and I know the routine is written appropriately especially because it works right up until it finishes. Activate doesn't work, enableEvents does nothing, on error statements are not triggered, changing the printing area to 5x5 results in same error after completion. Problem initially started by the program pausing, me switching screens and returning started it up again. Repairing, resetting, and reinstalling Excel didn't do it either. Thoughts?

 

Dim i As Integer, j As Integer, str As String
For i = 1 To 10
For j = 1 To 10
Cells(j, i).Value2 = world(i, j).getVector
Next j
Next i

1 Reply

@saintcolius 

should actually go through (untested)

Dim i As Integer, j As Integer, str As String
For i = 1 To 10
For j = 1 To 10
Cells(j, i).Value2 = world(i, j).getVector
Next j
Next i

 

For...Next statement

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/fornext-statement

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.