<img src="//trc.taboola.com/1222697/log/3/unip?en=page_view" width="0" height="0" style="display:none">


The Knowledgebase articles are deprecated. Please visit the new Guides and Resources here: https://www.uipath.com/developers/guides-and-resources.

Knowledge Base

Excel Automation.Delete Duplicate Rows


  • To be able to run this example you need to install UiPath.Excel.Activities. See more details on how to install packages here.


This sample sorts the values from an Excel sheet from the smallest to largest and then deletes duplicate rows.

Steps to automate

  1. Open Excel application
  2. Open "Sort" window
  3. Select sort options
  4. Save Excel file
  5. Remove duplicates from Excel
  6. Close Excel file


  1. Open Excel window using "Start Application" activity.
  2. All the data in the Excel sheet will be sorted using UiPath activity called "Send hotkey": Ctrl+a, Alt+d and then press s.
  3. In Sort window click "Column A", click "Smallest to Largest" and then click "OK".
  4.  Click save the Excel file because all the data from Excel will be loaded in a data table.
  5. Take everything from Sheet1 into DataTable using "Read Cell Range" activity.
  6. Use a "While" activity and a "rowIndex" variable to move forward in the data table rows. Compare the value of each row with the value of the next row. If the values are equal remove "rowNext", otherwise increment the row index with one. 
  7. With "Write Cell Range" activity, save the resulted data table in Sheet2.
  8. Close the Excel window.


Read more about Excel Automation.