ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing two Cells - using Offset and compare - Stuck!!!! (https://www.excelbanter.com/excel-programming/286670-comparing-two-cells-using-offset-compare-stuck.html)

Doug[_9_]

Comparing two Cells - using Offset and compare - Stuck!!!!
 
What is the easist way to compare the values of two adjacent cells? I need to check the value of the active cell and the cell to the right of it (i can use the offset for that). If the numerical value of the cell to the right is greater, than I trigger an alert. Simple stuff, but I am not totally sure how to define the cell to the right using the offset and then compare the values. Any help would be greatly appreciated. Thank you

Dou

Example
If A1 is less than B1 (A1 < B1) then I show a user form
The active cell in this case would be A1. I need to figure out code to calculate the offset (to B1) and then compare the values. Thanks.

Rob van Gelder[_4_]

Comparing two Cells - using Offset and compare - Stuck!!!!
 
Doug,

Sub testit()
Dim rng As Range

Set rng = Range("A1")

If rng.Value < rng.Offset(0, 1).Value Then
MsgBox "show form"
End If
End Sub

Rob

"Doug" wrote in message
...
What is the easist way to compare the values of two adjacent cells? I need

to check the value of the active cell and the cell to the right of it (i can
use the offset for that). If the numerical value of the cell to the right is
greater, than I trigger an alert. Simple stuff, but I am not totally sure
how to define the cell to the right using the offset and then compare the
values. Any help would be greatly appreciated. Thank you.

Doug

Example:
If A1 is less than B1 (A1 < B1) then I show a user form.
The active cell in this case would be A1. I need to figure out code to

calculate the offset (to B1) and then compare the values. Thanks.



Tom Ogilvy

Comparing two Cells - using Offset and compare - Stuck!!!!
 
if ActiveCell.Value < ActiveCell.offset(0,1).Value then _
userform1.show

--
Regards,
Tom Ogilvy

Doug wrote in message
...
What is the easist way to compare the values of two adjacent cells? I need

to check the value of the active cell and the cell to the right of it (i can
use the offset for that). If the numerical value of the cell to the right is
greater, than I trigger an alert. Simple stuff, but I am not totally sure
how to define the cell to the right using the offset and then compare the
values. Any help would be greatly appreciated. Thank you.

Doug

Example:
If A1 is less than B1 (A1 < B1) then I show a user form.
The active cell in this case would be A1. I need to figure out code to

calculate the offset (to B1) and then compare the values. Thanks.



Doug[_9_]

Comparing two Cells - using Offset and compare - Stuck!!!!
 
Rob/Tom

Thank you so much. That worked like a charm

Doug


All times are GMT +1. The time now is 02:53 AM.

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