Hide or delete rows with non-duplicate, unique values in first column

gideonfell

New Member
Joined
Oct 17, 2008
Messages
5
I have a spreadsheet with content IDs in the first column.

I want to analyze rows with duplicate content IDs. The other columns are not the same so the rows are not exact duplicates.

I need a formula or macro that will hide or delete rows with unique, non-duplicate values in the first column. Any suggestions?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
That filter hides duplicate rows. None of my rows are exact duplicates. It also keeps one row of a set of duplicates.
 
Upvote 0
The following assumes the matching Content_IDs are in consecutive rows, if not then at least this is a start.

Click the first Content_ID cell then:

Insert > Name > Define and in the 'Names in workbook:' box enter 'ID_Start', then click OK.

Right click on the sheet name, View Code and paste the following:

Public Sub DeleteDupeIDs()
'Replace Worksheets(1) as appropriate
Dim ID_StartRow, ID_EndRow, ID_Col, y As Integer
Dim R1, R2 As Range
ID_Col = Range("ID_Start").Column

ID_StartRow = Worksheets(1).Range("ID_Start").Row
ID_EndRow = Worksheets(1).Range(Cells(65535, ID_Col), Cells(65535, ID_Col)).End(xlUp).Row

Set R1 = Worksheets(1).Range(Cells(65535, 1), Cells(65535, 1))
For y = ID_StartRow To ID_EndRow
If Cells(y, ID_Col).Value = Cells(y - 1, ID_Col).Value Then
Set R2 = Worksheets(1).Range(Cells(y, 1), Cells(y, 1))
Set R1 = Union(R1, R2)
End If
Next y
'R1.Select
R1.EntireRow.Hidden = True
'R1.Delete
'Application.Goto Sheets(1).Cells(1, 1), True
End Sub

To Run, click Tools > Macro, Macros then DeleteDupeIDs and Run.

Regards
Anthony
 
Upvote 0
Whoops, just re-read your post, you want to hide/delete the unique rows not the duplicate rows. I'm not too hot with VBA, I could do this in C#. I'll give it some more thought.
 
Upvote 0
I've done something similar to this in C#.

The quick way to do this in C# would be to use a Dictionary or HashTable a quick search on google revealed this:

HASH TABLES
============
The best way to create hash tables in Excel VBA is to set a reference
to the Microsoft Scripting Runtime library. It contains a Dictionary
object that works like a Perl hash structure.
 
Upvote 0
Thanks, but I am not a programmer. I was hoping for a solution using a formula or macro.

I have a formula, for example, that uses conditional formatting to toggle highlighting of rows each time the content ID changes. I was hoping for a similar solution to hide or delete the rows with a unique content ID.
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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