Need to take data from top to bottom of columns A-AD and add them to a pivotTable using Excel Script [closed]

4 days ago 10
ARTICLE AD BOX

You need to use template literals:

let newPivotTable = workbook.addPivotTable("PivotTable1", selectedSheet.getRange(`A26:AD${lastRowAD}`), sheet2.getRange("A3"));

You probably also need to subtract by one when calculating lastRowAD to get the actual last-row:

let lastRowAD = colADUsed.getRowIndex() + colADUsed.getRowCount() - 1;

Majed Badawi's user avatar

Read Entire Article