ghp2017

New Member
Joined
Dec 12, 2017
Messages
39
Hello,

I created a macro to remove some cells that had a value of 0 but just realized that it actually ends up removing anything that ends in 0 as well. Anyone know how to fix this?

Sub UPLOAD_REMOVE_NULL_VALUE()
Sheets(3).Unprotect Password:="Genesis"
Dim i As Long, lr As Long
lr = Cells(Rows.Count, "E").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "E").Value Like "*[0]" Then
Range("E" & i).EntireRow.Delete
End If
Next i
Sheets(3).Protect Password:="Genesis", AllowFiltering:=True
End Sub
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,334
Office Version
  1. 2010
Platform
  1. Windows
Hello,

I created a macro to remove some cells that had a value of 0 but just realized that it actually ends up removing anything that ends in 0 as well. Anyone know how to fix this?

Sub UPLOAD_REMOVE_NULL_VALUE()
Sheets(3).Unprotect Password:="Genesis"
Dim i As Long, lr As Long
lr = Cells(Rows.Count, "E").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "E").Value Like "*[0]" Then
Range("E" & i).EntireRow.Delete
End If
Next i
Sheets(3).Protect Password:="Genesis", AllowFiltering:=True
End Sub
If I understand what you want correctly, change the highlighted line of code to this...

If Cells(i, "E").Value = 0 Then
 

Watch MrExcel Video

Forum statistics

Threads
1,109,501
Messages
5,529,238
Members
409,857
Latest member
KailuaTown
Top