Forum Discussion

Bhaskar Sharma's avatar
Bhaskar Sharma
Copper Contributor
Apr 08, 2018

Run-time error '1004': application-defined or object-defined error

Getting error in vba while writing a macro at this statement

ActiveCell.FormulaR1C1 =_
"=VLOOKUP (RC[-22],'[" & Shrin_FileName & "]TL and AM Wise'!C1:C4,4,0)"

3 Replies

  • "=VLOOKUP (RC[-22],'["" & Shrin_FileName & ""]TL and AM Wise'!C1:C4,4,0)"

    Try this.


     wrote:
    Getting error in vba while writing a macro at this statement

    ActiveCell.FormulaR1C1 =_
    "=VLOOKUP (RC[-22],'[" & Shrin_FileName & "]TL and AM Wise'!C1:C4,4,0)"

     wrote:
    Getting error in vba while writing a macro at this statement

    ActiveCell.FormulaR1C1 =_
    "=VLOOKUP (RC[-22],'[" & Shrin_FileName & "]TL and AM Wise'!C1:C4,4,0)"

     

    • Bhaskar Sharma's avatar
      Bhaskar Sharma
      Copper Contributor
      Hi Logaraj,
      The code worked with " however its not picking the value for the string Shrin_FileName.
      ActiveCell.FormulaR1C1 =_
      "=VLOOKUP (RC[-22],'["" & Shrin_FileName & ""]TL and AM Wise'!C1:C4,4,0)"

      This gives output as
      =VLOOKUP (C7,'[ & Shrin_FileName & ]TL and AM Wise'!C1:C4,4,0)"

Resources