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!
 
  • Suggested answer
    CU16071609-1 Profile Picture
    6,255 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 132

Last 30 days Overall leaderboard