Replacing zeros with blanks

Surreybloke

Board Regular
Joined
Apr 1, 2010
Messages
155
Office Version
  1. 365
Platform
  1. Windows
I have a macro that I got help with on here a few years ago, that replaces zeros with blanks across two different columns. I have another spreadsheet with different data that I want to apply the same methodology to in order to remove zeros, however, this time some cells have number strings I want to retain, and not lose the zeros. The only cells I want to be affected have a zero in and nothing else.

Is there a change that can be made to the code below to only change cells where there is a single zero to a blank, or will I need a brand new macro?

This is the code I currently have:

Sub ReplaceZeroesWithBlanks()
'
' ReplaceZeroesWithBlanks Macro
'

'
Sheets("Invoice File").Select
Columns("DJ:DK").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("DJ14").Select
Sheets("Macros").Select
Range("M30").Select
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top