title: Automatically execute a macro when a cell value is changed by a DDE/OPC link
body: <p>I need to execute a macro when a cell value is changed by an external DDE/OPC link.  I've tried several of the examples using the Worksheet_Change function, but this only seems to work when a user types in a value (and even then, only works once).</p>
  
  <p>Here's the entire code (after changing to the "Calculate" method):</p>
  
  <pre><code>Private Sub Worksheet_Calculate()  'Calculate command will execute the macro when any value change the spreadsheet to recalculate
     Dim ctr As Integer, n1 As String, v1 As Single, trigger As Long
  
     'Application.EnableEvents = False
     'Workbooks("Data Save.xls").Select
     Sheets("Sheet1").Select
     trigger = Range("b5").Value  'data save trigger cell linked to PLC
     If trigger = 1 Then
        Dim fn1 As String
        fn1 = "C:\11047 RR\" &amp; Range("B4") &amp; ".csv"   'build a filename
  
        Open fn1 For Output As 1
        Print #1, Range("a1"); ","; Range("B1") 'batch number
        Print #1, Range("a2"); ","; Range("B2") 'part number
        Print #1, Range("a3"); ","; Range("B3") 'pass number
        Print #1, Range("a4"); ","; Range("B4") 'filename
        Print #1, "Date &amp; Time:,"; Date$; ","; Time$
        For ctr = 7 To 69
           n1 = Sheets("Sheet1").Cells(ctr, 2).Value
           v1 = Sheets("Sheet1").Cells(ctr, 3).Value
           Print #1, ctr; ","; n1; ","; v1
        Next ctr
        Close 1
        Sheets("Sheet1").Cells(5, 4) = 0   'put a zero into cell D5 in the spreadsheet
        RSIchan = DDEInitiate("RSLinx", "Upsetter_11047")
        DDEPoke RSIchan, "DataSaveFlag", Range("D5") 'write cell D5 out to the trigger word
        DDETerminate (RSIchan)
        MsgBox "Data saved"
        Application.EnableEvents = True
  
  
     End If
  End Sub
  </code></pre>