Skip to main content

Notifications

Power Automate - General Discussion
Answered

How to change a specific cell in Excel

(0) ShareShare
ReportReport
Posted on by 11

I have an excel sheet stored on Sharepoint and I want to fill in info into a certain cell for example  C5 = value of script

 

How can we do this?

 

 

  • Re: How to change a specific cell in Excel

    I was able to do what I wanted with update rows instead. I didn't understand it before but I found something that was helpful. Thank you!

  • GeoffRen Profile Picture
    GeoffRen on at
    Re: How to change a specific cell in Excel

    Please take a look at these tutorials.

    Office Script basics

    Office Script Power Automate

    You need to create an Office Script and then use the Office Script here. Hardcoded scripts here are not supported.

  • Re: How to change a specific cell in Excel

    I keep getting this: 

      "Message""The request entity's media type 'text/plain' is not supported for this resource.\r\nclientRequestId: f7af027b-fa0c-439e-833e-2bd61b94cb0b". 
    Artemis22_0-1690463905131.png

    Here's what I put down as my script:

    Artemis22_2-1690464072263.png

     

     

  • GeoffRen Profile Picture
    GeoffRen on at
    Re: How to change a specific cell in Excel

    The following script will do what you want. 

    function main(workbook: ExcelScript.Workbook) {
     // Standard javascript date object operations to get the name of the previous month
     // I searched on google: 'js get previous month', found this site https://reactgo.com/javascript-get-previous-month-name/ and shamelessly repurposed it for the following
     const current = new Date();
     current.setMonth(current.getMonth() - 1);
     const previousMonth = current.toLocaleString('default', { month: 'long' });
    
     // Set 'previousMonth' as the value in some range in some worksheet
     workbook.getWorksheet("Sheet5").getRange("A1").setValue(previousMonth);
    }

     Output:

    GeoffRen_0-1677176893486.png

     

     

  • ZKBPCE-IT Profile Picture
    ZKBPCE-IT 19 on at
    Re: How to change a specific cell in Excel

    Hello @GeoffRen
    I think you can help me with my problem, i have an excel file that i duplicate evrey month, then i have to update a cell with the value of the first day of the last month. I tried to do this with the action "Update a row" in power automate, but it take more than 6min to update one cell. do you know others way fater to update a cell, maybe with the excel scripts ?
    thanks in advance for your response 

  • GeoffRen Profile Picture
    GeoffRen on at
    Re: How to change a specific cell in Excel

    Keep in mind that if you want to do this without using tables, you will have to use Office Scripts (specifically Office Scripts with Power Automate)? This is the 'Run Script' action on the Excel connector. With Office Scripts you can use the 'Run Script' action to execute javascript against a workbook. So, in your case, you would have a script that just assigns the value of a cell a parameter. So something like

     
    async function main(workbook: ExcelScript.Workbook, val: string) {
      workbook.getWorksheet('Sheet1').getRange('C5').setValue(val);
    }

     

  • Verified answer
    DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: How to change a specific cell in Excel

    Hi @aralvesbe 

     

    With update a row you can select the column and value as a reference and then update any of the columns within that row.

     

    DamoBird365_0-1615452991178.png

     

    DamoBird365_1-1615453005400.png

     

    This would update row 3, Dave to New Value

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard