Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Finding Dups in one column then delete leaving one

I have a list of Vendor numbers in Column A, I need to find the duplicates
that are in column A then delete the duplicates but leave one. How and where
do I write the formula for this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Finding Dups in one column then delete leaving one

If you are using Excel 2007, select column A, then select Remove Duplicates
on the Data ribbon.

In Excel 2003 & earlier, use 2 helper (empty) columns on the sheet that has
the duplicates. Enter this formula in row 1 in one helper column:
=Row()
Enter this formula in row 1 in the other helper column:
=IF(COUNTIF($A$1:$A1,A1)1,0,1)
Copy these two cells down through the last row of data (maybe the last
vendor number in column A). Press F9 to recalculate the spreadsheet. Now
select the two helper columns. Copy & paste special them in place as values.
Select all the data on the sheet and sort it by the second helper column (the
one that had the COUNTIF formula). Delete all the rows with a zero in that
column - these are the duplicates. Sort all the data again by the first
helper column; this puts the rows back in their original order minus the
deleted duplicates. Finally, delete the two helper columns.

Hope this helps,

Hutch

"Marc" wrote:

I have a list of Vendor numbers in Column A, I need to find the duplicates
that are in column A then delete the duplicates but leave one. How and where
do I write the formula for this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Finding Dups in one column then delete leaving one

You can use code like the following:


Sub DeleteDupRows()
Dim StartRow As Long
Dim EndRow As Long
Dim RNdx As Long
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With
StartRow = 1
EndRow = Cells(StartRow, "A").End(xlDown).Row
For RNdx = EndRow To StartRow Step -1
If Application.CountIf(Range(Cells(1, "A"), _
Cells(RNdx, "A")), Cells(RNdx, "A").Value) 1 Then
Rows(RNdx).Delete
End If
Next RNdx
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub





Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Tue, 13 Apr 2010 10:26:01 -0700, Marc
wrote:

I have a list of Vendor numbers in Column A, I need to find the duplicates
that are in column A then delete the duplicates but leave one. How and where
do I write the formula for this?

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
Delete Dups Stockwell43 Excel Discussion (Misc queries) 6 October 23rd 08 08:41 PM
delete a duplicate in column while leaving other duplicates daphoenix Excel Worksheet Functions 1 June 25th 08 04:15 PM
Find duplicates, sum and delete dups John Excel Programming 0 November 15th 06 01:31 AM
How to delete values in each row leaving only last value ? Oleg Excel Discussion (Misc queries) 1 March 10th 06 07:17 PM
How to delete rows with repeating values and leaving only one with highest value on the next column? Justin[_11_] Excel Programming 1 October 14th 04 06:30 AM


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

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

About Us

"It's about Microsoft Excel"