Category Archives: Excel VBA

Excel VBA: RsLinx DDE example

'Initialize DDE
channelNumber = Application.DDEInitiate("RSLinx", "SomeTopicName")

'Read from PLC5
readValue = DDERequest(channelNumber, "N20:1")
'Read from ControlLogix
readValue = DDERequest(channelNumber, "ControlLogixTag[1]")

'Write to PLC
Set rangeToPoke = Worksheet("Sheet1").Range("A1")

'Write to PLC5
Application.DDEPoke channelNumber, "N20:2", rangeToPoke
'Write to ControlLogix
Application.DDEPoke channelNumber, "ControlLogixTag[1]", rangeToPoke

'End DDE
Application.DDETerminate channelNumber

Excel VBA: Excel Version

Use Application.Version property to find out the version of Microsoft Excel. Useful to check for Microsoft Excel version to test the number of rows.

Example Syntax:

MsgBox (Application.Version)

Version Number:

  • 15.0 – 2013
  • 14.0 – 2010
  • 12.0 – 2007
  • 11.0 – 2003

Excel VBA: Speed up macro execution

Speed up macro execution by turning off screen updating/flicker.

'Turn Off Screen Updating
Application.ScreenUpdating = False
'Optional: Refresh/Update screen manually when needed

'Your Code

'Turn On Screen Updating
Application.ScreenUpdating = True