View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Can anyone correct this code ???

Can you have other data in the row in columns after "J"? If so, try this
version of the code instead (I should have coded it this way in the first
place) ...

***************** START OF CODE *****************
Sub DeleteRowsWithDataOnlyInAandJ()
Dim X As Long
Dim LastRow As Long
Dim OriginalCalculationMode As Long
Dim RowsToDelete As Range

On Error GoTo Whoops
OriginalCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

With ActiveSheet
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For X = LastRow To 3 Step -1
If .Cells(X, 1).Value < "" And .Cells(X, 10) < "" And _
WorksheetFunction.CountA(.Range(Cells(X, 1), _
Cells(X, 10))) = 2 Then
If RowsToDelete Is Nothing Then
Set RowsToDelete = .Cells(X, 1)
Else
Set RowsToDelete = Union(RowsToDelete, .Cells(X, 1))
End If
If RowsToDelete.Areas.Count 100 Then
RowsToDelete.EntireRow.Delete
Set RowsToDelete = Nothing
End If
End If
Next
End With
If Not RowsToDelete Is Nothing Then
RowsToDelete.EntireRow.Delete
End If

Whoops:
Application.Calculation = OriginalCalculationMode
Application.ScreenUpdating = True
End Sub
***************** END OF CODE *****************

--
Rick (MVP - Excel)


"colwyn" wrote in message
...

Rick Rothstein, thanks again. I've copy-pasted your code but when I
click "Run" absolutely nothing happens on the s/s
??????


--
colwyn
------------------------------------------------------------------------
colwyn's Profile: http://www.thecodecage.com/forumz/member.php?userid=34
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=44836