Surreybloke
Board Regular
- Joined
- Apr 1, 2010
- Messages
- 155
- Office Version
- 365
- Platform
- 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
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