willo1232
09-30-2010, 06:57 AM
Hi,
:help I need a macro to do the following function:help :
Check the data in one column. If that data equals 0 then look in a different column containing new data and check to see if that data equals the line above or the line below.
If no then leave.
If yes then delete the line that contained the 0 in the first column checked.
I have to date this:
Code:
Option Explicit
Sub DeleteRows()
Dim LastRow As Long
Dim i As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "A").Value = 0 Then
If Cells(i - 1, "B").Value = Cells(i, "B").Value Or _
Cells(i + 1, "B").Value = Cells(i, "B").Value Then
Cells(i, "A").EntireRow.Delete
End If
End If
Next i
End Sub
Unfortunately, this isn't working, as the lines aren't being deleted, and maybe not even identified as incorrect.:dunno
Please, Please, Please can someone help!!:help
Thanks,
:help I need a macro to do the following function:help :
Check the data in one column. If that data equals 0 then look in a different column containing new data and check to see if that data equals the line above or the line below.
If no then leave.
If yes then delete the line that contained the 0 in the first column checked.
I have to date this:
Code:
Option Explicit
Sub DeleteRows()
Dim LastRow As Long
Dim i As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = LastRow To 2 Step -1
If Cells(i, "A").Value = 0 Then
If Cells(i - 1, "B").Value = Cells(i, "B").Value Or _
Cells(i + 1, "B").Value = Cells(i, "B").Value Then
Cells(i, "A").EntireRow.Delete
End If
End If
Next i
End Sub
Unfortunately, this isn't working, as the lines aren't being deleted, and maybe not even identified as incorrect.:dunno
Please, Please, Please can someone help!!:help
Thanks,