teatimecrumpet
Active Member
- Joined
- Jun 23, 2010
- Messages
- 307
Hi,
The below code works at finding a cell with a negative number. Copying the row and inserting it above the row.
However, It will continually find that row and add that same row instead of moving on to the next real instance of a negative number.
Does anyone know how to get out of the loop and move on the next qcell?
Thanks!
The below code works at finding a cell with a negative number. Copying the row and inserting it above the row.
However, It will continually find that row and add that same row instead of moving on to the next real instance of a negative number.
Does anyone know how to get out of the loop and move on the next qcell?
Thanks!
Sub insert_row_when_cell_neg()
Dim SR As Long
Dim qcell As Range
Dim col2 As Range
SR = Cells(Rows.Count, 21).End(xlUp).Row
Set col2 = Range("U2:U" & SR)
For Each qcell In col2
If qcell.Value < 0 Then
qcell.EntireRow.Copy
qcell.Offset(0, -20).Insert (xlShiftDown)
End If
Next
End Sub