ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting zero values (https://www.excelbanter.com/excel-programming/321489-deleting-zero-values.html)

K McCurry

Deleting zero values
 
How do I delete zero values in cells? It would be great to have a macro to
run to remove any zero values.

Tom Ogilvy

Deleting 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

--
Regards,
Tom Ogilvy

"K McCurry" <K wrote in message
...
How do I delete zero values in cells? It would be great to have a macro

to
run to remove any zero values.




K McCurry[_2_]

Deleting zero values
 
Thank You!!! That worked Great!

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"K McCurry" <K wrote in message
...
How do I delete zero values in cells? It would be great to have a macro

to
run to remove any zero values.






All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com