Share via

IFERROR for Script

Anonymous
2024-04-02T20:30:02+00:00

I am trying to do an If error with a vlookup on for a scrip. It runs fine when I do it in the cell, but I get the following when I run the script.

Line 21: Range setFormulaLocal: The argument is invalid or missing or has an incorrect format.

What would cause the issue?

selectedSheet.getRange("G2").setFormulaLocal("=VLOOKUP(F2,'[KB KEY.xlsm]SKU'!$A$2:$B$202,2,FALSE)");
// Paste to extended range obtained by extending down from range G3 on selectedSheet from range G2 on selectedSheet
selectedSheet.getRange("G3").getExtendedRange(ExcelScript.KeyboardDirection.down).copyFrom(selectedSheet.getRange("G2"), ExcelScript.RangeCopyType.all, false, false);

// Set range I2 on selectedSheet
selectedSheet.getRange("I2").setFormulaLocal("=IFERROR(VLOOKUP(H2,'[KB KEY.xlsm]Finish'!$A$2:$C$44,3,FALSE),12");
selectedSheet.getRange("I3").getExtendedRange(ExcelScript.KeyboardDirection.down).copyFrom(selectedSheet.getRange("I2"), ExcelScript.RangeCopyType.all, false, false);
Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-03T03:27:57+00:00

    Try this one.

    ==================

    selectedSheet.getRange("I2").setFormulaLocal("=IFERROR(VLOOKUP(H2,'[KB KEY.xlsm]Finish'!$A$2:$C$44,3,FALSE),12)");

    ==================

    I'd suggest you create a new thread on Office Development which is special channel to handle Office Script issue.

    Office Development - Microsoft Q&A

    Thank you for your undestanding.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-04-03T00:58:45+00:00

    Dear Blair Neal,

    Thank you for posting to Microsoft Community. We are glad to assist. We are looking into your situation and we will update the thread shortly.

    Appreciate your patience and understanding and thank you for your time and cooperation.

    Sincerely,

    Hailey

    Was this answer helpful?

    0 comments No comments