Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compare value in cell A to value in Cell b and add 1
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 -- Kerry |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compare value in cell A to value in Cell b and add 1
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 --------------- Jacob Skaria "Kerry" wrote: 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 -- Kerry |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compare value in cell A to value in Cell b and add 1
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. -- Kerry "Jacob Skaria" wrote: 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 --------------- Jacob Skaria "Kerry" wrote: 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 -- Kerry |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compare value in cell A to value in Cell b and add 1
another way
[B4] = IIf([B4] = [C3], 1, [B4] + 1) "Kerry" a écrit dans le message de ... 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 -- Kerry |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
FIND / SEARCH text compare cell to string in 3rd cell | Excel Discussion (Misc queries) | |||
Compare text string of a cell in Column A VS another cell in Colum | Excel Discussion (Misc queries) | |||
Compare text string of a cell in Column A VS another cell in Colum | Excel Worksheet Functions | |||
Compare text string of a cell in Column A VS another cell in Colum | Excel Programming | |||
How do I compare cells and if FALSE compare to next cell in EXCEL | Excel Worksheet Functions |