ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help: Comparing two values (https://www.excelbanter.com/excel-programming/306025-help-comparing-two-values.html)

woknick[_7_]

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


Norman Jones

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/




Frank Kabel

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/



Soo Cheon Jheong[_2_]

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





All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com