Extracting data into Excel by DDE

sabarrett328

New Member
Joined
Apr 5, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I'm struggling with a statement in Excel. I'm trying to extract part data from a machine controller into Excel by DDE. I need to pull multiple sections of data from the controller and put them into multiple open files for analysis. I've done this before with only a single file, and a statement like this works fine:

data = DDERequest(coil, req)
Range(Cells(4, Index + 3), Cells(104, Index + 3)).Value = data

This pulls 100 pieces of data from my controller and places it in the current spreadsheet indicated by the range statement. Index is a looping variable as the data is a 100x100 array in the controller. In this example I was only pulling data out of one controller and placing it in the active spreadsheet.

However the new application I inherited has multiple arrays of data and multiple files to place the data. I tried to reconstruct the above as shown below (there are 5 more lines that drop more array data into 5 more files before looping to the next Index value):

data = DDERequest(rsichan1, "Recipe_Library_STF[" + CStr(Index) + ",0],l120,C120")
Range("[Tilt_recipe.csv]Tilt_recipe!" + Cells(Index + 1, 1), Cells(Index + 1, 120)).Value = data

It doesn't work. Considering the first example works fine, I'm sure its just my lack of knowledge of excel macros and their formats. I've attempted multiple searches for how to format this type of statement and have come up dry on the formatting.

I would like to edit this as the code I inherited doesn't use an index loop, instead it has 15 lines of code to pull each array row manually. Because there is 100 rows, that's over 1500 lines of code to edit. I really don't want to do that and risk errors in the data extraction. Does someone know what I am missing in my formatting to achieve this?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,214,655
Messages
6,120,760
Members
448,991
Latest member
Hanakoro

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