• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Replacing only Zero "0" from column without changing other number which contains 0

uday

Member
Hi

I want a VBA code that will replace only 0 from target column. My problem is whenever I am trying to replace the zero from entire column it is also replacing the other number which contains zero. My target is only replacing zero from column. If the zero is marge with other number it should remain same.

Please find the attachment.
 

Attachments

  • Sample3.xlsm
    7.9 KB · Views: 4
Something like this? If you are not replacing on the spot, you will need to modify code a bit.

Code:
Sub nullZero()
Dim lLast As Long
Dim ws As Worksheet

Set ws = Worksheets("Sheet1")

lLast = ws.Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To lLast
    If ws.Range("A" & i).Value = 0 Then
    ws.Range("A" & i).Replace 0, ""
    End If
Next i

End Sub
 
Back
Top