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 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 Super User 2025 Season 2 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

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard