
Announcements
Error: Runtime error: Line 13: Cannot read properties of undefined (reading 'getRangeBetweenHeaderAndTotal')
This script works outside power automate. Any idea why my table is showing up as undefined?
function main(workbook: ExcelScript.Workbook) {
//assigns var to current worksheet
let selectedSheet = workbook.getWorksheets()[0];
//assigns var to table in worksheet
const tableee = selectedSheet.getTable("Table1");
// Get the range containing all the cells with data or formatting.
let usedRange = tableee.getRangeBetweenHeaderAndTotal();
//gets range of 1st hyperlinked columnn
let range1 = usedRange.getColumn(0);
//gets range of 2nd hyperlink column
let range2 = usedRange.getColumn(4);
console.log(range1.getAddress());
//Get dimensions of table
let rowHeight = tableee.getRowCount();
let colWidth = 1;
//Loop through each item in col 1 and put hyperlink in farthest column
for (let i = 0; i < rowHeight; i++) {
for (let j = 0; j < colWidth; j++) {
let currHyperlink = range1.getCell(i, j).getHyperlink().address;
usedRange.getOffsetRange(0, 14).getCell(i, j).setValue(currHyperlink);
};
};
//Loop through each item in col 4 and put hyperlink in farthest column
for (let i = 0; i < rowHeight; i++) {
for (let j = 0; j < colWidth; j++) {
let currHyperlink = range2.getCell(i, j).getHyperlink().address;
usedRange.getOffsetRange(0, 15).getCell(i, j).setValue(currHyperlink);
};
};
};
I have a similar problem. It actually worked but since I create the worksheet automatically power automate has a hissi fit.
Any updates?