mojo
09-08-2000, 03:00 AM
I have the following code for working with an excel spreadsheet (obviously this is only part of the code):
AAA:
For Row1 = 3 To 300
With XLJob.Worksheets(2).Cells(Row1, 1)
If XLJob.Worksheets(2).Cells(Row1, 1) = "" Then
XLJob.Rows(Row1).Delete
End If
End With
Next Row1
For Row2 = 1 To 300
With XLJob.Worksheets(2).Cells(Row2, 1)
If XLJob.Worksheets(2).Cells(Row2, 1) = "" Then
GoTo AAA
End If
End With
Next Row2
To summarise, Row1 looks at each Row between 1 and 300 and deletes any blank rows. After that, Row2 relooks at each Row and if it encounters a blank row it reloops back to Row1 (so it can be deleted).
However, in the Row2 "For..Next" loop instead of saying:
If Row is blank, goto AAA
I want to be able to say:
If Row is blank AND if the are any rows between Row and row 2000 that ARE NOT blank, then goto AAA.
(Currently, say there are only 250 entries. The loop gets to row 251 and just loops forever. So I want my loop to be able to recognise the end of the recordset.)
Does anybody know how to do this?
Your help is much appreciated.
AAA:
For Row1 = 3 To 300
With XLJob.Worksheets(2).Cells(Row1, 1)
If XLJob.Worksheets(2).Cells(Row1, 1) = "" Then
XLJob.Rows(Row1).Delete
End If
End With
Next Row1
For Row2 = 1 To 300
With XLJob.Worksheets(2).Cells(Row2, 1)
If XLJob.Worksheets(2).Cells(Row2, 1) = "" Then
GoTo AAA
End If
End With
Next Row2
To summarise, Row1 looks at each Row between 1 and 300 and deletes any blank rows. After that, Row2 relooks at each Row and if it encounters a blank row it reloops back to Row1 (so it can be deleted).
However, in the Row2 "For..Next" loop instead of saying:
If Row is blank, goto AAA
I want to be able to say:
If Row is blank AND if the are any rows between Row and row 2000 that ARE NOT blank, then goto AAA.
(Currently, say there are only 250 entries. The loop gets to row 251 and just loops forever. So I want my loop to be able to recognise the end of the recordset.)
Does anybody know how to do this?
Your help is much appreciated.