Sunday, March 18, 2012

Replace zero with blank in excel

In financial sheets and calculation we want a utility to replace zero with blanks. Don't worry this can be achieved with a macro.




Press alt+F11 to view the vb code window.
Insert a new module and paste below code

---------------------------------------------------------------------------------------------

Sub replacezero()
Dim r As Range, rc As Range
Set rc = Nothing
For Each r In Selection
If Not IsEmpty(r) And r.Value = 0 Then
If rc Is Nothing Then
Set rc = r
Else
Set rc = Union(rc, r)
End If
End If
Next
rc.ClearContents
End Sub

-------------------------------------------------------------------------------------
Now assign a short cut key to this macro replacezero. Whenever you want to run the macro select the cells on which you want to run the macro and press the short cut keys already assigned.


No comments:

Post a Comment