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
Answered

Excel automation

(0) ShareShare
ReportReport
Posted on by 13

Hi,

I am using the free version power automate desktop. I have to read the data from the column named Causes/action id number in the Data worksheet and find a id match from the column named Causeid in the Causes worksheet. If the match is found I have to derive the value of cause from the cause column of the corresponding id in the Causes worksheet and place it in the data worksheet under the Causes column for the particular id. Can you help me create the flow.

I have attached the excel file for reference purpose.

 

Thank you!

I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Rpa123 

     

     

    You can give try with the below way to design this flow

     

     

     

    This is designed using common logic 

     

    1. Reading the data excel sheet

    2. Reading Causes excel sheet

    3. Looping through each row in data worksheet

    4. Lookup the cause ID from data worksheet to Causes worksheet, if value found update the data worksheet Causes column

    5. Finally write the updated data datatable to excel under data worksheet.

     

    Copy paste the below script for that 

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''D:\\Temp\\PAD_Question.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Data'''
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> DataFreeColumn FirstFreeRow=> DataFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 3 EndColumn: DataFreeColumn - 1 EndRow: DataFreeRow - 1 ReadAsText: False FirstLineIsHeader: True RangeValue=> DataExcel
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Causes'''
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> CauseFreeColumn FirstFreeRow=> CauseFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: CauseFreeColumn - 1 EndRow: CauseFreeRow - 1 ReadAsText: False FirstLineIsHeader: True RangeValue=> CauseExcelData
    SET rowindex TO 0
    LOOP FOREACH row IN DataExcel
     Variables.FindOrReplaceInDataTable.FindItemInDataTableByColumnIndex DataTable: CauseExcelData AllMatches: False ValueToFind: $'''id=\"%row['Cause/Action Id number']%\"''' MatchCase: False MatchEntireCellContents: True ColumnNameOrIndex: $'''CauseId''' DataTableMatches=> DataTableMatches
     IF DataTableMatches.RowsCount <> 0 THEN
     Text.ToNumber Text: DataTableMatches[0]['Row'] Number=> rowNumber
     Variables.ModifyDataTableItem DataTable: DataExcel ColumnNameOrIndex: $'''Causes''' RowIndex: rowindex Value: CauseExcelData[rowNumber]['Causes']
     END
     Variables.IncreaseVariable Value: rowindex IncrementValue: 1
    END
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''Data'''
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance Value: DataExcel Column: $'''A''' Row: 4
    Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
    

     

    Make sure to change the file path of excel used here in launch excel action before running the script. The output looks like this:

     

    Nived_Nambiar_0-1695448501316.png

     

    Note: may be u need to make changes in flow if you need to read file from A2 cell instead of A4 IN Data worksheet

     

     

     

  • Rpa123 Profile Picture
    13 on at

    This works perfectly!

     

    Thank you so much!

  • Rpa123 Profile Picture
    13 on at

    Hi Nived,

    Can you help me with the code in power automate. The process is same but here I need to read the parent ID column instead of cause column. I have to match the cause id number from causes sheet with the cause/action number id from the data sheet and read the corresponding value of parent ID column from the causes sheet and place it in the Parent ID column with the corresponding cause/action id number in the data worksheet.

     

    I have attached the excel file for reference. 

     

    This will be of great help.

     

    Thank you!

  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Rpa123 

     

    It seems like the change is only required for column name, in my earlier reply, we are updating Causes column , here we need to modify the flow to use the Parent ID column instead 

     

    Wherever we have mentioned column Causes, just change it to Parent ID both for lookup and update 🙂

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • Rpa123 Profile Picture
    13 on at

    This works too. Thank you!

     

    But I am facing another scenario too. First I need to capture the causes matching with the cause id as we have already done the new scenario includes after done entering the values of matched id's I have to check for the unmatched id's and insert the cause value in the data sheet along with the unmatched cause id in the cause\action id number column.

    Can you help me achieve this ?

     

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
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard