0

I need to insert a parameter into this:

row: workbook.getWorksheet("VittorioZigiotto").getRange("VittorioZigiotto[237]:Vittorioigiotto[241]")

The parameter need to be where now there is "237" and neet to depend on a cell in the workbook. For example, MONEYPAGE1!A1+5. Any ideas?

riky
  • 3
  • 2

1 Answers1

0

You can get the value you'd like instead of 237 from MONEYPAGE!A1 by doing something like:

const valueFromMPA1 = workbook.getWorksheet("MONEYPAGE").getRange("A1").getValue(); // use getValue for convenience since it's a single cell
const rowString = `VittorioZigiotto[${valueFromMPA1}]:VittorioZigiotto[${valueFromMPA1 + 5}]`; // this is a js/ts way to construct strings with params
// and then pass that in as the argument ...
const row = workbook.getWorksheet("VittorioZigiotto").getRange(rowString);

I'm not sure of your exact scenario, but also take a look at .getRangeByIndexes (instead of getRange), which lets you pass numeric row/column values instead of having to construct a string argument.

Sudhi Ramamurthy
  • 2,358
  • 1
  • 10
  • 14
Gergely
  • 106
  • 2