How to remove duplicates and replace with blank cells in Excel

gopinath1990

New Member
Joined
Apr 2, 2014
Messages
5
Hi All,

Please help regarding excel doubts since this is my first question to the forum and im a newbie,

1. How to remove duplicates and replace the rows the with blanks where other duplicates are present and leave the first row unchanged.

Thanks.

Have a great day
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This is untested as I just slapped it together but the logic is pretty sound. Make sure you test it on a COPY of your sheet so as to not do any damage.

Code:
Sub RemoveDupes()
Dim X As Long
For X = 1 To Range("A" & Rows.Count).End(xlUp).Row
    If Application.WorksheetFunction.CountIf(Range("A1:A" & X), Range("A" & X).Text) > 1 Then
        Rows(X).Delete
        X = X - 1 'Normaly you would go backwards when deleting rows but because we are using an expanding range we must go forwards and therefore take 1 away from X when deleting a row
    End If
    If X > Range("A" & Rows.Count).End(xlUp).Row Then Exit For 'This is to stop it from going bealistic if the last row is a dupe
Next
End Sub
 
Upvote 0
If however you want to leave the row intact but just blank out all the values, use this instead:

Code:
Sub RemoveDupes()
Dim X As Long
For X = 1 To Range("A" & Rows.Count).End(xlUp).Row
    If Application.WorksheetFunction.CountIf(Range("A1:A" & X), Range("A" & X).Text) > 1 Then Rows(X).ClearContents
Next
End Sub
 
Upvote 0
In excel I typed 6519991852611318.37 but automatically converrted to 6519991852611310.00 last digit and decimals automatically how can it changed pls help me
 
Upvote 0

Forum statistics

Threads
1,214,896
Messages
6,122,132
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top