Learn how to use Microsoft Excel VBA to read and write data from Microsoft Excel to ControLogix using RSLinx.

Note that to read the values from the Allen-Bradley PLC, the Microsoft Excel spreadsheet need not be a Excel Macro-Enabled Workbook. However, if you have to write to the Allen-Bradley PLC, the Microsoft Excel spreadsheet has to be a Excel Macro-Enabled Workbook.

Below is a quick overview of what you need to do in order to read to the ControlLogix PLC from Microsoft Excel spreadsheet via RSLinx Gateway.
1) Create a topic
Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Create Topic
A topic name with a lock means that the topic is currently connected via DDE connection.

Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Create New DDE Topic

2) Copy DDE/OPC Link from the Edit pull down menu.
Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Copy DDE/OPC Link

Select the item and click on OK. The Data Table Address will be copied to your clipboard.
Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Copy DDE/OPC Link

3) In your Microsoft Excel spreadsheet, right-click on any cell and select Paste Special from the context menu.
Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Special Paste

Select Paste link and then click on OK button.
Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Paste Link

4) You should see a Microsoft Excel formula for DDE like in the screenshot below.

Xybernetics Microsoft Excel RSLinx Gateway ControlLogix Formula for DDE

To write a value to the ControlLogix PLC from Microsoft Excel spreadsheet via RSLinx Gateway, is a bit involved. Please see the YouTube video below.

Below is the VBA source code to write value to the Allen-Bradley ControlLogix PLC.

Sub Button1_Click()
DDEChannel = Application.DDEInitiate(app:=”RSLinx”, topic:=”NEW_TOPIC”)
DDEItem = “Local:2:I.Data.1”
Set RangeToPoke = Worksheets(“Sheet1”).Range(“B14”)
Application.DDEPoke DDEChannel, DDEItem, RangeToPoke
Application.DDETerminate DDEChannel
End Sub

https://youtu.be/wgAOheexqto