View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default VBA reset cell value if greater then 0

Sub ResetAll()
Dim myRng As Range

For Each myRng In Sheets("Sheet1").Range("C21:C31")

If myRng.Value < "" Then myRng.Value = 0
Next myRng
End Sub


--
__________________________________
HTH

Bob

wrote in message
...
Hi,

I have this macro to reset cells in C21-C31 to 0.
However, how do I amend this macro that it will only re-set the cells
to 0 if it the cell contains a value greater then 0 as I do not wish
for the macro to add a 0 to cells that are empty with no cell values
in them at all.

Sub ResetAll()
Dim myRng As Range

Set myRng = Sheets("Sheet1").Range("C21:C31")

myRng.Value = "0"

End Sub

Is it possible to do this?

Thanks!