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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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 said:
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.
 
if ActiveCell.Value < ActiveCell.offset(0,1).Value then _
userform1.show

--
Regards,
Tom Ogilvy

Doug said:
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.
 
Back
Top