Can anyone correct this code ???
Your specification says "delete rows which dont (sic) have data in
column I". However, your code is set to clear rows that have exactly 2
filled cells in columns A:J.
To meet your first objective (blanks in I), one way:
Public Sub delRowsinColumnI()
Dim rClear As Range
Dim rCell As Range
With ActiveSheet
For Each rCell In .Range(.Cells(3, 9), _
.Cells(.Rows.Count, 1).End(xlUp).Offset(0, 8))
If IsEmpty(rCell.Value) Then
If rClear Is Nothing Then
Set rClear = rCell
Else
Set rClear = Union(rClear, rCell)
End If
End If
Next rCell
End With
If Not rClear Is Nothing Then rClear.EntireRow.Delete
End Sub
In article ,
colwyn wrote:
This code is designed to delete rows which dont have data in column I.
However, after several hours running, it just freezes up the s/s and I
have to close it down.
Code:
--------------------
Sub delRows()
Dim rClear As Range
Dim Rw As Long
Dim LastRw As Long
With ActiveSheet
LastRw = .Cells(.Rows.Count, 1).End(xlUp).Row
For Rw = LastRw To 3 Step -1
If Application.WorksheetFunction.CountA(.Range(.Cells (Rw, 1), .Cells(Rw,
10))) = 2 Then
If rClear Is Nothing Then
Set rClear = .Cells(Rw, 1)
Else: Set rClear = Union(rClear, Cells(Rw, 1))
End If
End If
Next Rw
rClear.EntireRow.Delete
End With
End Sub
--------------------
|