Share via

Problem triggering VBA code off a cell changed though a DDE link

Anonymous
2019-10-14T17:11:57+00:00

I have a DDE link established between RSLINX (this is the tag server for an Allen Bradley PLC) and Excel. I'm trying to trigger some VBA code off a change in one cell (A1 as 0 or 1), which is read in Excel from the server as this:

=RSLINX|EXCEL_TEST!'Trigger_to_Excel,L1,C1'

Using the code below, which I grabbed from Microsoft, I can get the Excel code to run, but only if I manually modify the above trigger cell. The update in value through the DDE link does not register as a change, even though the value flips from 0 to 1. Any ideas...???

Private Sub Worksheet_Change(ByVal Target As Range)

Dim KeyCells As Range

' The variable KeyCells contains the cells that will

' cause an alert when they are changed.

Set KeyCells = Range("A1:A1")

If Not Application.Intersect(KeyCells, Range(Target.Address)) _

Is Nothing Then

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2019-10-15T01:18:19+00:00

    Hi.  I have never done this:

    Workbook.SetLinkOnData method (Excel)

    Sets the name of a procedure that runs whenever a DDE link is updated.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-10-15T14:52:39+00:00

    Sub UpdateDDE()

    ActiveWorkbook.SetLinkOnData _

        "RSLINX|EXCEL_TEST!'Trigger_to_Excel,L1,C1'", _

        "RMG"

    End Sub

    Was this answer helpful?

    0 comments No comments