remirenaud
New Member
- Joined
- Oct 28, 2014
- Messages
- 2
I need help going from the Excel INDEX command to proper VBA code. I have up to 90 Excel files used for surveying clinic participants. Since each survey will have the questions in a different order, the VBA code needs vertically index to the proper question in the respondents’ files. The clinic may have up to 10 competitive products, but only a maximum of 4 are allowed to be evaluated per question (so this could be a different 4 for each question) so a horizontal index is also required to index to the proper ratings in the row, of which there are three different ratings per product: Likes, Dislikes and a Numeric rating. Each response is then concatenated with the respondents name in the upper left of the file and all are concatenated together into a single cell so that the team can evaluate all the responses in a single cell of text (except the numerics, which are averaged) This is repeated for up to 300 questions (rows). I have a version working where the indexing is performed in Excel using INDEX, but it requires two sheets as Excel has a limit of 8192 characters in a cell formula, and it includes files, even if they are not used. I would prefer to select the files to be used and then place the resulting text only into the cells.
Below is the excel formula I use, reduced down to only 3 files (vs. 90) to save space - In this example it looks for the question # in $B7, and calls the product selected of the 10 (Cell P7) and is looking for the “Dislikes” (thus the P7 & ”D”).
= [C01.xlsx]C!$C$2&"@ "&(INDEX([C01.xlsx]C!$A$6:$AL$600,MATCH($B7,[C01.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C01.xlsx]C!$A$6:$AL$6,0)))&":
"& [C02.xlsx]C!$C$2&"@ "&(INDEX([C02.xlsx]C!$A$6:$AL$600,MATCH($B7,[C02.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C02.xlsx]C!$A$6:$AL$6,0)))&":
"& [C03.xlsx]C!$C$2&"@ "&(INDEX([C03.xlsx]C!$A$6:$AL$600,MATCH($B7,[C03.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C03.xlsx]C!$A$6:$AL$6,0)))
Below is the excel formula I use, reduced down to only 3 files (vs. 90) to save space - In this example it looks for the question # in $B7, and calls the product selected of the 10 (Cell P7) and is looking for the “Dislikes” (thus the P7 & ”D”).
= [C01.xlsx]C!$C$2&"@ "&(INDEX([C01.xlsx]C!$A$6:$AL$600,MATCH($B7,[C01.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C01.xlsx]C!$A$6:$AL$6,0)))&":
"& [C02.xlsx]C!$C$2&"@ "&(INDEX([C02.xlsx]C!$A$6:$AL$600,MATCH($B7,[C02.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C02.xlsx]C!$A$6:$AL$6,0)))&":
"& [C03.xlsx]C!$C$2&"@ "&(INDEX([C03.xlsx]C!$A$6:$AL$600,MATCH($B7,[C03.xlsx]C!$A$6:$A$600,0),MATCH(P7&"D",[C03.xlsx]C!$A$6:$AL$6,0)))