PC Review


Reply
Thread Tools Rate Thread

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

 
 
Kerry
Guest
Posts: n/a
 
      6th Jun 2009
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 With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Jun 2009
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

 
Reply With Quote
 
Kerry
Guest
Posts: n/a
 
      6th Jun 2009
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

 
Reply With Quote
 
Charabeuh
Guest
Posts: n/a
 
      7th Jun 2009
another way

[B4] = IIf([B4] >= [C3], 1, [B4] + 1)


"Kerry" <(E-Mail Removed)> a écrit dans le message de
news:5647E596-0A86-458D-ACF6-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FIND / SEARCH text compare cell to string in 3rd cell =?Utf-8?B?bmFzdGVjaA==?= Microsoft Excel Misc 0 29th Oct 2007 02:51 AM
Compare text string of a cell in Column A VS another cell in Colum =?Utf-8?B?VGFu?= Microsoft Excel New Users 2 1st Aug 2007 09:45 AM
Compare text string of a cell in Column A VS another cell in Colum =?Utf-8?B?VGFu?= Microsoft Excel Misc 1 1st Aug 2007 09:03 AM
Compare text string of a cell in Column A VS another cell in Colum =?Utf-8?B?VGFu?= Microsoft Excel Programming 0 30th Jul 2007 05:12 PM
Cell compare and based on the value change the cell background color pftiv Microsoft Excel Worksheet Functions 2 15th Jan 2004 04:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.