WindsorKnot
Board Regular
- Joined
- Jan 4, 2009
- Messages
- 160
Hi,
I'm having trouble with my code below.
Basically I want the code to determine if the cell before and after the active cell contains a value and if both these conditions are true to delete the active row.
I keep getting a runtime error 1004 when I try this.
Thanks!
I'm having trouble with my code below.
Basically I want the code to determine if the cell before and after the active cell contains a value and if both these conditions are true to delete the active row.
I keep getting a runtime error 1004 when I try this.
Thanks!
Code:
Sub rowdelete()
Dim i As Integer
Sheet4.Activate
For i = 1 To 30000
If Cells(i, 1).Value = IsEmpty(ActiveCell) Then
If Cells(i, 1).Offset(-1, 0).Value = "" _
And Cells(i, 1).Offset(1, 0).Value = "" Then
Cells(i, 1).Select
Selection.Delete Shift:=xlUp
End If
End If
Next i
End Sub