if column A and column B on selected row are equal...

wisewood

Board Regular
Joined
Nov 7, 2002
Messages
193
I need to know how to check if column A and column B are equal on the selected row.

ie. if i am on row 221, i want to check that A221 and B221 are equal... and if they are, run MyMacro()... or if i am on row 9957585 then it checks to see if A9957585 = B9957585.

You get the point I'm sure.

I want to trigger it by exiting specific cells - but i already know how to do that.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Something like this perhaps:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(Target.Row, 1) = Cells(Target.Row, 2) Then
    'macro code here
End If
End Sub
 
Upvote 0
There are 2 types of events you might be looking for: Change Event or SelectionChange Event.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Rw = Target.Row
If Cells(Rw, 1) = Cells(Rw, 2) Then
    'Enter your code
End If

End Sub
This would run every time you make a change in the sheet

Or this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Cells(Rw, 1) = Cells(Rw, 2) Then
    'Enter your code
End If

End Sub
would run every time you select a new cell. These actually check the row it just left. Adjustments could be made to change that if you need.
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top