Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
FIND / SEARCH text compare cell to string in 3rd cell nastech Excel Discussion (Misc queries) 0 October 29th 07 02:51 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Discussion (Misc queries) 1 August 1st 07 09:03 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Worksheet Functions 1 August 1st 07 09:01 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Programming 0 July 30th 07 05:12 PM
How do I compare cells and if FALSE compare to next cell in EXCEL Cindie Excel Worksheet Functions 0 March 24th 06 05:29 PM


All times are GMT +1. The time now is 08:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"