Hi There
Please see the following code. I want the macro to delete 5 rows if the user clicks on a sub task (this part works). The tricky part is if a user clicks on a main task, the macro should delete rows one by one beneath it till it finds a main task (where the value in Column B=1), and then STOP. Currently, it finds ALL rows in the spreadsheet where Column B=1 and deletes them!
Thanks!
S
[VBA]Sub DeleteTask01()
'
'
Dim SelectedRow As Long
SelectedRow = ActiveCell.row
If Cells(SelectedRow, 2).Value <> 1 Then
Range("B" & SelectedRow & ":B" & SelectedRow + 5).EntireRow.Delete
Else
Dim i As Long
For i = SelectedRow To 999
If Cells(i, 2).Value <> 1 Then
Cells(i,2).EntireRow.Delete
End If
Next i
End If
End Sub[/VBA]