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 Comparison

(1) ShareShare
ReportReport
Posted on by 12

I have two Excel files:

  • The first file contains 25,000 rows
  • The second file contains 250 rows

I need to compare these two files and extract the rows from the first file that are not present in the second file, then store the result in a new Excel file.

Although I can achieve this using the "For Each" and "If" activities, this method results in high time complexity. Additionally, if an error occurs midway, it becomes difficult to troubleshoot and handle.

Is there an alternative approach to achieve this efficiently, similar to how we use LINQ queries in UiPath, that reduces time complexity and simplifies the process?

 

Here i will give sample example:

Excel File 1:

ID Name
1 Alice
2 Bob
3 Charlie
4 David
5 Eve
 

Excel File 2:

ID Name
1 Alice
3 Charlie
5 Eve
 

Expected Output:

ID Name
2 Bob
4 David
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    I assume that you are running the flow from the Edit window? Running it from there is meant for only debugging and development. So even if you have Run delay set to 1ms it will still take much longer than if you run the flow Attended/Unattended or from the Power Automate Desktop "My flows" screen and just press "Run" on the flow


    For example I have test flow that loops Excel file that has 5000 rows in it. It will take around 10 seconds to run the flow. But if I run it in Edit window it will take about 6 minutes (with run delay at minimum 1ms).

    So consider running the flow from the Run button in the window where all your flows are.

    Then you could add error handling that if error happens it adds LastError -variable (you get that by using "Get last error" -action) to a error list/datatable and the loop that failed. Then just continues to do the rest of the loop. And then in the end the error datatable or list you write into some text file named "ErrorList.txt".

    Here is an example to get the idea. It tries to do the loop 3 times and if it goes to error 3 times then write the error on a txt file and goes to next loop item.


    And this is how the error txt file looked like:
  • Suggested answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
    Hey Hi,
     
    Please try this below method as shown in images.
     
     
     
    Code;
     
    Please copy the below code to your flow.
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\Desktop\\Power Automate Desktop\\Practice\\Excel\\Community\\Excel1.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance1
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance1 Value: $'''Tempo''' Column: $'''C''' Row: 1
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\Desktop\\Power Automate Desktop\\Practice\\Excel\\Community\\Excel2.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance2
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance1 Value: $'''=VLOOKUP(B2,[Excel2.xlsx]Sheet2!$B:$B,1,0)''' Column: $'''C''' Row: 2
    Excel.CopyCellsFromExcel.CopyCell Instance: ExcelInstance1 StartColumn: $'''C''' StartRow: 2
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance1 FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.SelectCellsFromExcel.SelectCells Instance: ExcelInstance1 StartColumn: $'''C''' StartRow: 2 EndColumn: $'''C''' EndRow: FirstFreeRow - 1
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: ExcelInstance1 TextToSend: $'''{Control}({V})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    WAIT 2
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance1 ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    Variables.FindOrReplaceInDataTable.ReplaceItemInDataTableEverywhere DataTable: ExcelData AllMatches: True ValueToFind: -2146826246 MatchCase: False MatchEntireCellContents: True TextToReplaceWith: $'''NA''' DataTableMatches=> DataTableMatches
    Variables.FilterDataTable DataTable: ExcelData FilterParameters: { ^['RULE', 'COLUMN', 'OPERATOR', 'VALUE'], [$'''Or''', 2, $'''Equal''', $'''NA'''] } FilteredDataTable=> FilteredDataTable
    Variables.DeleteColumnFromDataTable.DeleteColumnWithIndex DataTable: FilteredDataTable ColumnIndex: 2
    Excel.LaunchExcel.LaunchUnderExistingProcess Visible: True Instance=> ExcelInstance3
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance3 Value: FilteredDataTable.ColumnHeadersRow Column: $'''A''' Row: 1
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance3 Value: FilteredDataTable Column: $'''A''' Row: 2
    
     
    (Note:- if you got your solution you can mark as solution and gives kudos)
     
    Thanks & Regards
    Vishnu Reddy

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