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 Automate
Suggested Answer

Excel Variable

(1) ShareShare
ReportReport
Posted on by 2
After counting the rows in an Excel file, cell C2 contains the total. How can I turn this into a variable for a for each loop? Thanks!
 
I have the same question (0)
  • Suggested answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at
     
    You can read the C2 value using "Read from Excel" action and assign into variable then you can use that variable in the for each loop.

    Flow screenshot:



    PAD code(Copy and paste the below code into your power automate desktop flows):
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Deenu\\Book1.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadNamedCell Instance: ExcelInstance CellName: $'''C2''' ReadAsText: False TrimEmptyCells: False RangeValue=> ExcelData
    SET TotalRows TO ExcelData[0][0]
    

     
    Thanks,
    Deenu
  • Suggested answer
    mathiaskjeldsen Profile Picture
    224 on at
    Hi
     
    Automating Excel tasks are quite heavily supported in Power Automate Desktop. You're situation would require you to assign the cell to a variable by using Set Variable action. If you need a visual representation of it, I've done something quite similar here: Automate Excel finance tasks with Power Automate Desktop.
     
    Best regards
    Mathias Kjeldsen
     
    ---
    If this has helped solve your problem, please mark it as an helpful answer.
     
    Connect with me on social platforms by using the links below.
    YouTube: https://www.youtube.com/@matkjeldsen 
    LinkedIn: https://www.linkedin.com/in/mathiaskjeldsen/

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 957

#2
Valantis Profile Picture

Valantis 847

#3
Haque Profile Picture

Haque 609

Last 30 days Overall leaderboard