I have a VBA module I have written for a .DAT file that I am running through Excel.
The code is working as expected until I run into this section:
...
...VB Code:
i = 1 Set sortCell = r1.Cells(i, 20) Set r1 = ActiveSheet.Range(Cells(1, 1), Cells(A, 20)) Do While i < A sortCell.Value = r1.Cells(1, 1).Value & "|" & r1.Cells(1, 5).Value & "|" & r1.Cells(1, 6).Value & "|" & r1.Cells(1, 7).Value & "|" & r1.Cells(1, 8).Value & "|" & r1.Cells(1, 9).Value & "|" & r1.Cells(1, 10).Value & "|" & r1.Cells(1, 11).Value & "|" & r1.Cells(1, 12).Value & "|" & r1.Cells(1, 13).Value & "|" & r1.Cells(1, 14).Value & "|" & r1.Cells(1, 15).Value & "|" & r1.Cells(1, 16).Value & "|" & r1.Cells(1, 17).Value & "|" & r1.Cells(1, 18).Value Set sortCell = sortCell.Offset(1, 0) Set r1 = r1.Offset(1, 0) i = i + 1 Loop
There are 37011 rows in the sheet this month. 37011 is the value of A and is calculated in a previous section.
When I get to Set r1 = r1.Offset(1, 0) I get a 1004 Application-defined or object-defined error. This occurs in row 28527 of the spreadsheet.
The application allows sortCell row to get set to 28527 but when it tries to increase the range row from 28526 to 28527, I get the error message.
I use watch to track the values.
Has anyone run into this and have any advice?
thanks




Reply With Quote