Forum Discussion
AnthonyC1730
Sep 29, 2024Copper Contributor
Define variable in my VBA to clean my code (error)
Hello, I would like to define variable in the top of my VBA to reference file and range (column) to make then Index/match function. Defining variable at the top of my code will be more convenient...
- Sep 30, 2024
Steve_SumProductCom
Thank you very much, I did a small adjustment to your code because it was taking the col 1 and 7 of the extract.xlsx instead of the source file (see print screen below).But with the code below, it is working perfectly! Thank you. Very helpful.
.Range("B2:B" & NBrow1).FormulaR1C1 = "=INDEX(" & MDART_G2.Address(External:=True, ReferenceStyle:=xlR1C1) & ",MATCH(RC[-1]," & MDART_CODE.Address(External:=True, ReferenceStyle:=xlR1C1) & ",0))"
AnthonyC1730
Sep 30, 2024Copper Contributor
Please find below a print screen of the error I get (I left other code commented that I tried too without success):
https://www.evernote.com/shard/s586/sh/8ef409e1-d72e-f940-88c0-2fc22790407b/Ct936I4kbE5zQVfj3dUpnOqrCdkqf5BlLasECd8-5p5pgyJxBFnwJ_aZcw
Thank you.
https://www.evernote.com/shard/s586/sh/8ef409e1-d72e-f940-88c0-2fc22790407b/Ct936I4kbE5zQVfj3dUpnOqrCdkqf5BlLasECd8-5p5pgyJxBFnwJ_aZcw
Thank you.
Sep 30, 2024
BTW - you can share screen shots directly in this forum by using the "Open full text editor" link to write your reply. Then you can just paste images directly into the reply.
- AnthonyC1730Sep 30, 2024Copper Contributor
Ok sorry, I did not see full text editor before.
Here below the images:
VBA Code (line error in Yellow):
extract.xlsx file opended when I execute the macro:
- Sep 30, 2024Please also share the actual error message that appears when you run the macro.
- AnthonyC1730Sep 30, 2024Copper Contributor