Removing duplicates keep the first value and the blank cells

Steven1988

New Member
Joined
Mar 10, 2014
Messages
2
Hi guys!

I am new to this forum. I'm having a bit of problem.
I am trying to remove duplicates but i need to keep the blanks and the top values.
This is the tricky part, the values recurring in a group and im trying to keep the top values on that group
For example:

initial:
amber
amber
amber
james
james
james
amber
amber
amber
katie
katie

Prefered result:
amber


james


amber


katie


It would be very helpful if you guys could help me on this problem.

Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try something like this...

Code:
[color=darkblue]Sub[/color] Top_Of_Groups()
    [color=darkblue]Dim[/color] i [color=darkblue]As[/color] [color=darkblue]Long[/color]
    Application.ScreenUpdating = [color=darkblue]False[/color]
    [color=darkblue]For[/color] i = Range("A" & Rows.Count).End(xlUp).Row [color=darkblue]To[/color] 2 [color=darkblue]Step[/color] -1
        [color=darkblue]If[/color] Cells(i, "A") = Cells(i - 1, "A") [color=darkblue]Then[/color] Cells(i, "A").ClearContents
    [color=darkblue]Next[/color] i
    Application.ScreenUpdating = [color=darkblue]True[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Thank you alpha for your help.

This might sound stupid.. but i do not familiar on using VBA codes. Do you mind enlighten me on how to use this code?

Thank you!
 
Upvote 0
hi there

apologies for resurrecting an old thread but I found this page via google and it has very much helped me with a problem which is causing me to tear my hair out at the moment. However, I was hoping someone might help me modify the code mentioned in this thread to fully reach my aim.

i have a dataset similar to steven1988 i.e. recurring values in a group and I wish to keep the top values. rather than 'ClearContents' of the duplicate values, I would like to move the duplicate rows to another worksheet, where I can then re-run the code keeping the top values in Worksheet 2 and moving the remaining values to Worksheet 3 and so on. So nothing will be deleted but just moved. I have typed out what i mean below:

Initial Worksheet 1Worksheet 2Worksheet 3Worksheet 4
11
11
22
22
22
33
33
33
33
44
44
55
55
55
55
66
66
77
88
88
88
88
99

<colgroup><col><col span="4"></colgroup><tbody>
</tbody>

is this possible?

Any help very much appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,597
Members
449,038
Latest member
Arbind kumar

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