markjarvisltd
Board Regular
- Joined
- Sep 17, 2004
- Messages
- 92
I have the current code but it keeos failing at the delete row line
Can anyone explain why?
Private Sub CommandButton1_Click()
Dim iRow As Integer
Dim iRowsProcessed As Integer
Dim bAnotherBlank As Boolean
iRowsProcessed = 0
Application.ScreenUpdating = False
Application.Calculation = xlManual
For iRow = 1 To 200
bAnotherBlank = True
If Cells(iRow, 1).Value = "" Then
iRow.EntireRow.Delete
' Have we just moved another blank up to replace
' the one we deleted?
While (bAnotherBlank = True) And (iRowsProcessed < 200)
If Cells(iRow, 1).Value = "" Then
iRow.EntireRow.Delete
Else
bAnotherBlank = False
End If
iRowsProcessed = iRowsProcessed + 1
Wend
Else
iRowsProcessed = iRowsProcessed + 1
End If
Next iRow
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
Can anyone explain why?
Private Sub CommandButton1_Click()
Dim iRow As Integer
Dim iRowsProcessed As Integer
Dim bAnotherBlank As Boolean
iRowsProcessed = 0
Application.ScreenUpdating = False
Application.Calculation = xlManual
For iRow = 1 To 200
bAnotherBlank = True
If Cells(iRow, 1).Value = "" Then
iRow.EntireRow.Delete
' Have we just moved another blank up to replace
' the one we deleted?
While (bAnotherBlank = True) And (iRowsProcessed < 200)
If Cells(iRow, 1).Value = "" Then
iRow.EntireRow.Delete
Else
bAnotherBlank = False
End If
iRowsProcessed = iRowsProcessed + 1
Wend
Else
iRowsProcessed = iRowsProcessed + 1
End If
Next iRow
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub