View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default VBA reset cell value if greater then 0

try
Sub ResetAll()
Dim myRng As Range, c As Range
Set myRng = Sheets("Sheet1").Range("C21:C31")
For Each c In myRng
If c.Value 0 Then
c.Value = 0
End If
Next
End Sub

Mike

" wrote:

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!