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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / office script EXCEL: g...
Power Automate
Unanswered

office script EXCEL: get last row

(0) ShareShare
ReportReport
Posted on by 21

Hello all

 

im doing my first office script:

 

function main(workbook: ExcelScript.Workbook) {
  let selectedSheet = workbook.getActiveWorksheet();
  // Set range Y1:Y2 on selectedSheet
  selectedSheet.getRange("Y1:Y2")
    .setValues([
      ["Date"],
      ["=TEXT(TODAY(),'mm.dd.yyyy')"]
    ]);
  // Set width of column(s) Y1 to 73.5
  selectedSheet.getRange("Y1")
    .getFormat()
    .setColumnWidth(73.5);
  // Auto fill range
  selectedSheet.getRange("Y2")
    .autoFill("Y2:Y52"ExcelScript.AutoFillType.fillDefault);
}
 
and i need 2 things:
 
1. the formula to fill a cell with date fails....im pretty sure that is a problem with quotes
2. i need how to calculate last row to apply the auto fill
 
regards
Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,985 Most Valuable Professional on at

    Hi @javier_perez 

     

    This community is related to Power Automate. Your question is more focused on Excel formula. 

     

    Please post your question to below community.

     

    The Microsoft Excel Community

     

    Thanks

  • javier_perez Profile Picture
    21 on at

    hello

     

    but the formula works on desktop excel and web excel...the problem is when i execute the script in power automate

     

    regards

  • javier_perez Profile Picture
    21 on at

    for question 1:

     

    i have to escape the quotes with '\' 

    "=TEXT(TODAY(),\"mm.dd.aaaa\")"
  • Yutao Huang Profile Picture
    Microsoft Employee on at

    @javier_perez -

     

    Regarding your question to find the last row, I'm wondering if you have tried Range.getSurroundingRegion( ) . I think that should work as long as there are no completely blank rows or blank columns within the range.

     

    https://docs.microsoft.com/en-us/javascript/api/office-scripts/excelscript/excelscript.range?view=of...

     

    -Yutao

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard