Share via

VBA Code for Delete Duplicate Rows

Anonymous
2015-10-23T05:36:55+00:00

Hi All,

Request you to provide VBA code for delete duplicate rows

Data before delete duplicate rows

Name     Subject     Marks

Ravi         Maths      90

Rahul       Physics   85

Raju         Science   75

Raju         Science    75

Ravi         Maths       90

Data after deleting duplicates

Name     Subject     Marks

Ravi         Maths      90

Rahul       Physics   85

Raju         Science   75

Request you to provide VBA code. Thanks in advance,

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Vijay A. Verma 104.9K Reputation points Volunteer Moderator
    2015-10-23T07:13:35+00:00
    1. Save your file as .xlsm
    2. ALT+F11
    3. Locate your Workbook name in Project Explorer Window
    4. Right click on your workbook name > Insert > Module 
    5. Copy paste the below code in this
    6. ALT+F8 to display Macro Window
    7. Run your Macro from here
    8. If Sheet1 is not the sheet, replace it appropriately.

    Sub DuplicateDelete()

        ThisWorkbook.Sheets("Sheet1").UsedRange.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes

    End Sub

    Was this answer helpful?

    0 comments No comments
  2. OssieMac 48,001 Reputation points Volunteer Moderator
    2015-10-23T07:07:33+00:00

    You can use the Remove Duplicates function in Excel.

    1. Select the range (including Column Headers)
    2. Select Data Ribbon
    3. Click Remove duplicates icon (in the Data tools block)
    4. Follow the prompts in the dialog box.

    If you turn on the Macro recorder before you do this and then stop the recorder after removing the duplicates then you will have the required code. If you then require help to make the range dynamic (so that it works with any number of rows) then post the recorded code and I will edit it to make it dynamic.

    Was this answer helpful?

    0 comments No comments