Replace zero with nothing - ,acro

blaksnm

Well-known Member
Joined
Dec 15, 2009
Messages
554
Office Version
  1. 365
Platform
  1. Windows
Hey Guys
I try to record a macro that replace all single-zeros (just the cells where one zero-character is the whole input) with blanc (I want to emty all cells that contain this singel zero-character.

I know i have seen something like this before, but dont remember where ..
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try

Code:
Sub test()
Cells.Replace What:="0", Replacement:="", LookAt:=xlWhole
End Sub
 
Upvote 0
Thanks - that macro works ... in a way ...
I use the tecnique to count cells containing something else than zero (skip counting blanks) on a range.
Your macro replaces zero with blanc all right, but still - when i use the count-formulas on the range - the cells seems to contain some hidden characters ore something that make my formula respond with a count. This is only correctet when I use the delete-button on the appearently emty cell.
Are there a way around this problem?
 
Upvote 0
why not just use a formula?

=countif(A1:Z99,"<>0")-countblank(A1:Z99)
 
Upvote 0
Good sugestion, but as long as the "empty" cells value is som kind of hidden value the formula wil not read this as blank
 
Upvote 0
I meant use the formula without clearing the 0 values first.

=countif(A1:Z99,"<>0") will count all cells that have anything other than 0 (which will include empty cells if there are any)

then -countblank(A1:Z99) will subtract the count of empty cells (if any) to give a true count of non 0 values.<!-- / message -->
 
Upvote 0
Thanks a lot for your advise - Ill try it
 
Upvote 0
I have a way of doing what you asked originally, but the macro recorder doesn't recognise what is being done, and so far no luck in finding any way to code it, to do it manually.

Ctrl F

Find What : 0

Options >> Match entire cell contents -- yes

Find All

Ctrl A

Escape

Delete
 
Upvote 0
Thanks again :)
The problem seems to be solved
Have a nice weekend
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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