VBA: worksheet row overflow error 'Run-time error '6' Overflow using worksheets().Range

25 views Asked by At

I have a vba program that is filling a sheet with the results of a simulation. One line of code is:

Dim RunCounter As Integer
Dim Margin (250,000, 5) as Variant

Worksheets("Optimization").Range("s", & RunCounter + 2) = Margin(Runcounter, 0)

When RunCounter gets to a value of 32766 so the row total is 32768, I get an overflow error

Run-time error '6': Overflow

I am not sure why I am getting this since excel allows many more rows.

Any ideas?

I don't know what to try. Since Worksheets is not dimensioned, I am not sure what to do

0

There are 0 answers