Run macro when 2 cells are equal

R.Thynes

New Member
Joined
Apr 9, 2002
Messages
1
Mr. Excel,

I am using MS Excel 97 as a data acquisition program. A serial device is sending data to a specific cell (4,6) via DDE. The numeric value of this incoming data varies between 0 and 360.

I want to execute a macro when the incoming data (the data in 4,6) becomes equal to a preset constant that I have placed in another cell (4,8).

This may be a simple task, but I have not found a working example from the FAQ lists yet.


Cordially,

Russell Thynes
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Put the following code in the module for your worksheet that contains the cells in question:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set Target = Cells(4, 6)
If Target = Cells(4, 8) Then MsgBox "Cells are equal"
End Sub

Replace the Msgbox function with the Call function and your macro.

_________________
Hope this helps.
Kind regards, Al.
This message was edited by Al Chara on 2002-04-10 16:04
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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