Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help: Comparing two values

I have 2 numbers that I want to compare to each other.
The first number is in B4 and the second is in C4. The comparison wil
be

if C4 < B4 Then
'Do something

how can I create a loop to perform this check on rows B4 through B2
and C4 through C24. so that each row will be compared.

thanks in advanc

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Comparing two values

Hi Woknick,

Try:

Sub test02()
Dim cell As Range

For Each cell In Range("C4:C24")
If cell.Value cell.Offset(0, 1) Then
'Do something
End If
Next

End Sub


---
Regards,
Norman



"woknick " wrote in message
...
I have 2 numbers that I want to compare to each other.
The first number is in B4 and the second is in C4. The comparison will
be

if C4 < B4 Then
'Do something

how can I create a loop to perform this check on rows B4 through B24
and C4 through C24. so that each row will be compared.

thanks in advance


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Comparing two values

Hi
one way:

sub foo()
dim i as integer
for i = 4 to 24
with cells(i,2)
if .value.offset(0,1).value then
'do something
end if
end with
next
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


I have 2 numbers that I want to compare to each other.
The first number is in B4 and the second is in C4. The comparison

will
be

if C4 < B4 Then
'Do something

how can I create a loop to perform this check on rows B4 through B24
and C4 through C24. so that each row will be compared.

thanks in advance


---
Message posted from http://www.ExcelForum.com/


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Comparing two values

Hi,

Option Explicit
Sub TEST()

Dim CL As Range
Dim i As Long

For Each CL In Range("B4:B24")
i = i + 1
If CL(i) CL(i, 2) Then

'Do something

End If
Next

End Sub



--
Regards,
Soo Cheon Jheong
_ _
^ ^
V



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
Help with Comparing values and retrieving values in Excel!!!!!! [email protected] Excel Worksheet Functions 1 November 17th 06 12:21 AM
Comparing values between columns only when there are values in bot Mark K Excel Worksheet Functions 1 February 19th 06 06:47 PM
Comparing values Dirk_Bob Excel Discussion (Misc queries) 2 August 24th 05 09:39 PM
comparing two values Jerry Excel Worksheet Functions 2 March 2nd 05 04:34 PM
Comparing Values Todd Huttenstine[_2_] Excel Programming 7 December 1st 03 06:37 AM


All times are GMT +1. The time now is 11:41 PM.

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"