Compare value in cell A to value in Cell b and add 1

K

Kerry

Hi,
When I run a VBA program in excel 2003 I want to compare the value in cell
B4 to the value in C3. If B4 < C3 then add 1 to B4 if not continue until
B4=C3 then reset to 1.
If B4<C3+1 else "1"
How do I write this in VBA?

Thankyou
 
J

Jacob Skaria

Kerry, do you mean...somthing like this in Activesheet.

Sub Macro()
'other code
If Range("B4") < Range("C3") Then
Range("B4") = Range("B4") + 1
ElseIf Range("B4") = Range("C3") Then
Range("B4") = 1
End If
'other code
End Sub

If this post helps click Yes
 
K

Kerry

Thanks Jacob,
That's exactly what I meant. You must be a mind reader cause it works
perfectly.
Much appreciate the time and knowledge you offer to others.
 

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

Top