0

When trying to create a named range for a formula that uses relative reference. In R1C1 notation, it would be R[1]C[1]. But any possibility I tried gave me an absolute path. Even if I did "=Sample!B1", I would see a "=Sample!$B$1" created. Is there a way to create a relative reference named range, without reverting to INDIRECT or INDEX strategy?

  await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    sheet.names.add("RelativeCell", "=Sample!R[1]C[1]")
    await context.sync();
  });
Rafael
  • 31
  • 4

1 Answers1

0

could you use a range object when you created a named range? You can use R1C1 notation for the range object.

range = sheet.getRange("A1:D1"); 
names.add("RelativeCell", range);
Raymond Lu
  • 2,178
  • 1
  • 6
  • 19
  • It's about the formula you are setting the named range with. – Rafael Dec 13 '19 at 00:01
  • What is "names" in this context? I've tried setting "worksheet.names.add", but "name" is undefined in the worksheet object. Also in the workBook object. What's the correct syntax here? Bottom line: how do you set a name for a range of sets in ExcelJs? – Simon Gillbee Feb 10 '21 at 23:03