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 / Filling the empty cell...
Power Automate
Answered

Filling the empty cells in Excel with a value in a particular column

(0) ShareShare
ReportReport
Posted on by 24

In Excel there are many empty cells in a Column, PAD should identify the empty cells in that column and fill the cellls with a particular text HELLO

Initially,

Swatiba_0-1677655479770.png

Output should be,

Swatiba_1-1677655525817.png

I have implemented in this way, but the text is not written in the empty cells.

Swatiba_2-1677656011802.png

Swatiba_3-1677656068589.png

Any help regarding this, would be helpful

 

I have the same question (0)
  • Verified answer
    momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    In your write to excel action you need to provide cell coordinates (row and column) but you are providing value that you read from excel.

    So in other words you tell PAD to write "Hello" to cell in row "null" and column "null".

     

    So you need to track the index of the value. You can do that using Loop instead of For each.

    Copy below and paste to your flow.

    Note how LoopIndex and ExcelData.RowsCount and try to understand why 😉

     

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\XXXXX\\Desktop\\test.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: False RangeValue=> ExcelData
    LOOP LoopIndex FROM 0 TO ExcelData.RowsCount - 1 STEP 1
     IF IsEmpty(ExcelData[LoopIndex][0]) THEN
     Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: $'''Hello''' Column: $'''A''' Row: LoopIndex + 1
     END
    END
    Excel.CloseExcel.Close Instance: ExcelInstance

     

    Then, once you learn how to automate this with loops, do it with way more efficient way 😉

    Add Column1 and Column2 headers to your flow, change the Sheet name to "Sheet1" and run this:

     

    SET Excel_File_Path TO $'''C:\\Users\\XXXX\\Desktop\\test.xlsx'''
    Database.Connect ConnectionString: $'''Provider=Microsoft.ACE.OLEDB.12.0;Data Source=%Excel_File_Path%;Extended Properties=\"Excel 12.0 Xml;HDR=YES\";''' Connection=> SQLConnection
    Database.ExecuteSqlStatement.Execute Connection: SQLConnection Statement: $'''UPDATE [Sheet1$]
    SET [Column1] = \"Hello\"
    WHERE [COLUMN1] IS NULL''' Timeout: 30 Result=> QueryResult
    Database.Close Connection: SQLConnection

     

    And you might want to check this this:

    https://learn.microsoft.com/en-us/power-automate/desktop-flows/how-to/sql-queries-excel

     

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

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 223

#2
David_MA Profile Picture

David_MA 210 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 175

Last 30 days Overall leaderboard