sabarrett328
New Member
- Joined
- Apr 5, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- 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?
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?