Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 119
Default Remove Repeats in a Column

I have a column of data and i would like to remove the repeats in the same
column or maybe with a helper column. See below:

Example:

ColumnA ColumnB

John Doe John Doe
John Doe
Kim Smith Kim Smith
Kim Smith
Kim Smith
Kim Smith
Dav Hodge Dav Hodge
Dave Hodge

Thanks.







  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,276
Default Remove Repeats in a Column

Hi,
This macro is thanks to CPearson

Public Sub DeleteDuplicateRows()
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''
' DeleteDuplicateRows
' This will delete duplicate records, based on the Active Column. That is,
' if the same value is found more than once in the Active Column, all but
' the first (lowest row number) will be deleted.
'
' To run the macro, select the entire column you wish to scan for
' duplicates, and run this procedure.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''

Dim R As Long
Dim N As Long
Dim V As Variant
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Set Rng = Application.Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Columns(ActiveCell.Column))

Application.StatusBar = "Processing Row: " & Format(Rng.Row, "#,##0")

N = 0
For R = Rng.Rows.Count To 2 Step -1
If R Mod 500 = 0 Then
Application.StatusBar = "Processing Row: " & Format(R, "#,##0")
End If

V = Rng.Cells(R, 1).Value
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
' Note that COUNTIF works oddly with a Variant that is equal to vbNullString.
' Rather than pass in the variant, you need to pass in vbNullString
explicitly.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
If V = vbNullString Then
If Application.WorksheetFunction.CountIf(Rng.Columns( 1), vbNullString)
1 Then
Rng.Rows(R).EntireRow.Delete
N = N + 1
End If
Else
If Application.WorksheetFunction.CountIf(Rng.Columns( 1), V) 1 Then
Rng.Rows(R).EntireRow.Delete
N = N + 1
End If
End If
Next R

EndMacro:

Application.StatusBar = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Duplicate Rows Deleted: " & CStr(N)

End Sub

Hope this helps

"Steve C" wrote:

I have a column of data and i would like to remove the repeats in the same
column or maybe with a helper column. See below:

Example:

ColumnA ColumnB

John Doe John Doe
John Doe
Kim Smith Kim Smith
Kim Smith
Kim Smith
Kim Smith
Dav Hodge Dav Hodge
Dave Hodge

Thanks.







  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 138
Default Remove Repeats in a Column

Try this:

1) Make sure that the first row in the column has a column header.
2) On the Data menu, point to Filter, and then click Advanced Filter.
3) In the Advanced Filter dialog box, click Copy to another location.
4) If the column (or range) that you are evaluating is not already selected,
delete any information in the List range box and then click the column (or
select the range) that contains your data.
5) In the Copy to box, delete any information in the box or click in the
box, and then click a blank column where you want to copy the unique values.
6) Select the Unique records only check box, and click OK.
7) The unique values from the selected range are copied to the new column.

Then you can delete the first column and keep only the column with the
unique names.

Paula

"Steve C" wrote:

I have a column of data and i would like to remove the repeats in the same
column or maybe with a helper column. See below:

Example:

ColumnA ColumnB

John Doe John Doe
John Doe
Kim Smith Kim Smith
Kim Smith
Kim Smith
Kim Smith
Dav Hodge Dav Hodge
Dave Hodge

Thanks.







  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 119
Default Remove Repeats in a Column

Thanks. This was helpful. is there a way to accomplish this without runing
the macro?

"Eduardo" wrote:

Hi,
This macro is thanks to CPearson

Public Sub DeleteDuplicateRows()
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''
' DeleteDuplicateRows
' This will delete duplicate records, based on the Active Column. That is,
' if the same value is found more than once in the Active Column, all but
' the first (lowest row number) will be deleted.
'
' To run the macro, select the entire column you wish to scan for
' duplicates, and run this procedure.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''

Dim R As Long
Dim N As Long
Dim V As Variant
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Set Rng = Application.Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Columns(ActiveCell.Column))

Application.StatusBar = "Processing Row: " & Format(Rng.Row, "#,##0")

N = 0
For R = Rng.Rows.Count To 2 Step -1
If R Mod 500 = 0 Then
Application.StatusBar = "Processing Row: " & Format(R, "#,##0")
End If

V = Rng.Cells(R, 1).Value
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
' Note that COUNTIF works oddly with a Variant that is equal to vbNullString.
' Rather than pass in the variant, you need to pass in vbNullString
explicitly.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''
If V = vbNullString Then
If Application.WorksheetFunction.CountIf(Rng.Columns( 1), vbNullString)
1 Then
Rng.Rows(R).EntireRow.Delete
N = N + 1
End If
Else
If Application.WorksheetFunction.CountIf(Rng.Columns( 1), V) 1 Then
Rng.Rows(R).EntireRow.Delete
N = N + 1
End If
End If
Next R

EndMacro:

Application.StatusBar = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Duplicate Rows Deleted: " & CStr(N)

End Sub

Hope this helps

"Steve C" wrote:

I have a column of data and i would like to remove the repeats in the same
column or maybe with a helper column. See below:

Example:

ColumnA ColumnB

John Doe John Doe
John Doe
Kim Smith Kim Smith
Kim Smith
Kim Smith
Kim Smith
Dav Hodge Dav Hodge
Dave Hodge

Thanks.







  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 119
Default Remove Repeats in a Column

Thanks Paula, i'm familiar with the unique records function. I'm looking to
replace the repeats in the column with a blank space to maintain the current
cell positions. Is there a formula that can do that? Thanks!

"Paula" wrote:

Try this:

1) Make sure that the first row in the column has a column header.
2) On the Data menu, point to Filter, and then click Advanced Filter.
3) In the Advanced Filter dialog box, click Copy to another location.
4) If the column (or range) that you are evaluating is not already selected,
delete any information in the List range box and then click the column (or
select the range) that contains your data.
5) In the Copy to box, delete any information in the box or click in the
box, and then click a blank column where you want to copy the unique values.
6) Select the Unique records only check box, and click OK.
7) The unique values from the selected range are copied to the new column.

Then you can delete the first column and keep only the column with the
unique names.

Paula

"Steve C" wrote:

I have a column of data and i would like to remove the repeats in the same
column or maybe with a helper column. See below:

Example:

ColumnA ColumnB

John Doe John Doe
John Doe
Kim Smith Kim Smith
Kim Smith
Kim Smith
Kim Smith
Dav Hodge Dav Hodge
Dave Hodge

Thanks.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Sequential Repeats Jakobshavn Isbrae Excel Discussion (Misc queries) 2 February 9th 09 04:27 PM
frequency a number repeats in a column Ken Excel Worksheet Functions 5 March 8th 07 04:12 AM
=sum(A:A) add to column (B) and new value repeats w/ new sums planecents Excel Worksheet Functions 3 March 2nd 07 06:35 PM
function for finding repeats in a column... killertofu Excel Worksheet Functions 2 February 21st 06 09:03 PM
no repeats in a column repeat Excel Worksheet Functions 2 November 3rd 04 10:36 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"