Skip to main content
Version: v6.5.0

Delete duplicate rows

Command Description

Delete duplicate rows in a worksheet by checking one or more columns that contain duplicate values

Command Prototype

Excel.RemoveDuplicates(objExcelWorkBook,sheet,selectRange,haveHeader,columnList,bSave)

Command parameter

parametermandatorytypedefault valueInstructions
objExcelWorkBookTrueexpressionobjExcelWorkBookWorkbook objects returned by the Open Excel Workbook command (Excel. Open) or Bind Excel Workbook command (Excel. BindBook)
sheetTruestring"Sheet1"If a string is used, it represents the name of the specified worksheet; Using numbers indicates the order of the specified worksheet (starting from 0)
selectRangeTruestring"A1:B8"Specify the cells in the selected area, or directly specify the area
haveHeaderTruebooleanFalseThe default is' No ', which means that the first row of the selected area participates in the calculation of duplicate values; Set to 'Yes', which means that the first row of the selected area does not participate in the calculation of duplicate values
columnListTruearray["A","B"]You can specify one or more columns in the selected area that contain duplicate values for inspection, represented in array format, supporting both column names (such as ["A", "B"]) and the number of columns in the selected area (such as [1,2]); For example, if the selected area is E10:H22, If the columns containing duplicates are columns E and H, they can be represented by ["E", "H"] or [1,4]
bSaveTruebooleanFalseDo you want to save immediately after completing the operation

Return result

Run instance

/********************************* Remove Duplicate Rows ***************************************
Command Prototype:
Excel.RemoveDuplicates(objExcelWorkBook, sheet, selectRange, haveHeader, columnList, bSave)
Input Parameters:
objExcelWorkBook -- Workbook object. Note: The workbook object returned by the "Excel.Open" command or the "Excel.BindBook" command.
sheet -- Worksheet. Note: If a string is used, it specifies the name of the worksheet; if a number is used, it specifies the index of the worksheet (starting from 0).
selectRange -- Selected range. Note: Specifies the cells within the selected range, or directly specifies the range.
haveHeader -- Data contains headers. Note: Defaults to "No", meaning the first row of the selected range is included in duplicate value calculation; set to "Yes", meaning the first row of the selected range is excluded from duplicate value calculation.
columnList -- Columns containing duplicate values. Note: One or more columns within the selected range to check for duplicates can be specified, represented in array format, supporting both column names (e.g., ["A","B"]) and column indices within the selected range (e.g., [1,2]). Example: If the selected range is E10:H22, and the columns containing duplicates are E and H, it can be represented as ["E","H"] or [1,4].
bSave -- Save immediately. Note: Whether to save immediately after the operation is completed.
Output Parameters:
None
Notes:
None
Excel.RemoveDuplicates(objExcelWorkBook,"Sheet1","A1:B8",False,["A","B"],False)