I have the following code:
Sub test() Dim nws As Worksheet 'new sheets to add template Dim tws As Worksheet Dim Cht As ChartObject Dim i As Range Dim sp As Chart 'for scatterplot Dim zone As Range Set tws = ThisWorkbook.Sheets("Template") For Each nws In ThisWorkbook.Worksheets
If nws.Name <> "Template" And nws.Name <> "Protocol" And nws.Name <> "Record Sheet" Then
nws.Select
Set zone = nws.Range("D2", Range("D2").End(xlDown))
zone.NumberFormat = "0.00"
For Each i In zone
If i.Value < 0 Then
i.EntireRow.Delete
End If
Next i
End If Next nws
End Sub
When a cell is less than zero it deletes the entire row. The problem with this is that the row below it moves up and becomes the active cell, therefore it essentially get "skipped" when the code runs 'next i'. This "skipped" cell may contain a -1 and doesnt get deleted because it essentially got skipped in the process.
I was wondering how to go back one row after the current row gets deleted?
I've tried:
i.offset(-1,0).activate
OR
Activecell.offset(-1,0).activate
But i just get error messages