Deleting zero values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I delete zero values in cells? It would be great to have a macro to
run to remove any zero values.
 
If you don't want to see them, you can go to tools=>Options=>View and
uncheck Zeros.

If you really want to remove them

dim rng as Range, cell as Ragne
Dim rng1 as Ragne
on error resume next
set rng = Activesheet.UsedRange.Specialcells(xlConstants, xlNumbers)
set rng1 = Activesheet.UsedRange.SpecialCells(xlFormulas, xlNumbers)
On Error goto 0
if not rng is nothing then
for each cell in rng
if cell.value = 0 then cell.clearcontents
next
end if
if not rng1 is nothing then
for each cell in rng1
if cell.value = 0 then cell.clearcontents
next
end if
 
Thank You!!! That worked Great!

Tom Ogilvy said:
If you don't want to see them, you can go to tools=>Options=>View and
uncheck Zeros.

If you really want to remove them

dim rng as Range, cell as Ragne
Dim rng1 as Ragne
on error resume next
set rng = Activesheet.UsedRange.Specialcells(xlConstants, xlNumbers)
set rng1 = Activesheet.UsedRange.SpecialCells(xlFormulas, xlNumbers)
On Error goto 0
if not rng is nothing then
for each cell in rng
if cell.value = 0 then cell.clearcontents
next
end if
if not rng1 is nothing then
for each cell in rng1
if cell.value = 0 then cell.clearcontents
next
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top