SAMCRO2014
Board Regular
- Joined
- Sep 3, 2015
- Messages
- 160
I have search previous threads and have tried different coding to delete the entire row of data if the value in column M (12) is zero to no avail. Getting very frustrated as this should be pretty simple coding. I must have a syntax error somewhere as it will only delete one row at a time when I run the macro.
Sub CleanSPS()
'
' CleanSPS Macro
'
Dim SPS As Worksheet
Set SPS = ActiveWorkbook.Sheets("SPS+")
Dim LastRowSPS As Long
LastRowSPS = SPS.Cells(Rows.Count, 12).End(xlUp).Row
Dim p As Long ' for projection
'Delete rows that contain a projection value of "0" in column L
For p = 3 To LastRowSPS
If Cells(p, 12).Value = 0 Then
Cells(p, 12).EntireRow.Delete
End If
Next p
MsgBox "Finished"
End Sub
Can you see my error?
Sub CleanSPS()
'
' CleanSPS Macro
'
Dim SPS As Worksheet
Set SPS = ActiveWorkbook.Sheets("SPS+")
Dim LastRowSPS As Long
LastRowSPS = SPS.Cells(Rows.Count, 12).End(xlUp).Row
Dim p As Long ' for projection
'Delete rows that contain a projection value of "0" in column L
For p = 3 To LastRowSPS
If Cells(p, 12).Value = 0 Then
Cells(p, 12).EntireRow.Delete
End If
Next p
MsgBox "Finished"
End Sub
Can you see my error?
Last edited: