View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
okrob okrob is offline
external usenet poster
 
Posts: 142
Default examine value, leave it or increment it

On May 1, 12:21 pm, Ivano wrote:
Hi,
I want a macro that will examin cells within range A1 to A10 and if it is
equal to or less then 5 leave it alone else increment it by one.

Thanks
Ivano,


This should work.
Rob

Sub test()
Dim myCell As Range, rng As Range
Set rng = Range("A1:A10")
For Each myCell In rng
If Abs(myCell) 5 Then myCell = myCell + 1
Next
End Sub