web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Excel Script: table sh...
Power Automate
Unanswered

Excel Script: table showing up as undefined in Power Automate

(0) ShareShare
ReportReport
Posted on by 6

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);
 };
 };
};

 

 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on at

    I have a similar problem. It actually worked but since I create the worksheet automatically power automate has a hissi fit.
    Any updates?

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard