0

I have created VBA that opens another excel and takes value from another cells. I use index, indirect function:

 ActiveCell.FormulaR1C1 = _
 "=IF(RC[-13]=0,"""",IFERROR(INDEX(INDIRECT(""'[excel 2020 07 BB_v1.xlsm]""&MID(CELL(""filename"",R1C1),FIND(""]"",CELL(""filename"",R1C1))+1,255)&""'!$N$2:$N$512""),MATCH(RC[-13],INDIRECT(""'[excel 2020 07 BB_v1.xlsm]""&MID(CELL(""filename"",R1C1),FIND(""]"",CELL(""filename"",R1C1))+1,255)&""'!$A$2:$A$512""),0)),""N/A""))"
   Range("N2").Select

I want to assign the cell with the excel name that I will not need to change every time the title of the name (excel 2020 07) in the code. Could you please help me?

Thank you

Dovile L.
  • 17
  • 4

1 Answers1

0

Concatenate strings (and variables) with &:

ActiveCell.FormulaR1C1 = "=IF(RC[-13]=0,"""",IFERROR(INDEX(INDIRECT(""'[" & Range("N2").Value & " BB_v1.xlsm]""&MID

You might benefit from reading How to avoid using Select in Excel VBA.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73