Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Formula to Delete Duplicates but keep one record

I am looking for a Formula that can delete all of the duplicates but keep one
record. I want the entire row to be deleted if it is a duplicate, and I do
not want to use a filter. I need this function for a Macro and the Macro
does not like using a filter.
For example,
1
2
2
3
1
4
2
3

Should only show at the end of the formula.
1
2
3
4

Any advice would be appreciated!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Formula to Delete Duplicates but keep one record

Posting your code might help us help you alittle more but this might do.

Sub RemoveDuplicates()
Dim whatColumn As Integer
Dim lr As Long
whatColumn = 1 '1 = A
lr = ActiveSheet.Cells(Rows.Count, whatColumn).End(xlUp).Row
ActiveSheet.Range("$A$1:$E$" & lr)_
.RemoveDuplicates Columns:=whatColumn, Header:=xlYes
End Sub

"Lost in Excel" wrote:

I am looking for a Formula that can delete all of the duplicates but keep one
record. I want the entire row to be deleted if it is a duplicate, and I do
not want to use a filter. I need this function for a Macro and the Macro
does not like using a filter.
For example,
1
2
2
3
1
4
2
3

Should only show at the end of the formula.
1
2
3
4

Any advice would be appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Formula to Delete Duplicates but keep one record

Hi,

Macros have no problem with filters. However, here is code to remove
duplicated:

in this case my duplicate data is in A1:A1111

Sub RemoveDuplicates()
Dim Bottom As Long
Columns("B:B").Insert
Bottom = [A1].End(xlDown).Row
Range("B1:B" & Bottom).Select
Selection = "=1/(COUNTIF(R1C[-1]:RC[-1],RC[-1])1)"
Selection.SpecialCells(xlCellTypeFormulas, 1).EntireRow.Delete
Columns("B:B").Delete
End Sub

If this helps, please click the Yes button.

Cheers,
Shane Devenshire

"Lost in Excel" wrote:

I am looking for a Formula that can delete all of the duplicates but keep one
record. I want the entire row to be deleted if it is a duplicate, and I do
not want to use a filter. I need this function for a Macro and the Macro
does not like using a filter.
For example,
1
2
2
3
1
4
2
3

Should only show at the end of the formula.
1
2
3
4

Any advice would be appreciated!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Formula to Delete Duplicates but keep one record



"Lost in Excel" wrote:

I am looking for a Formula that can delete all of the duplicates but keep one
record. I want the entire row to be deleted if it is a duplicate, and I do
not want to use a filter. I need this function for a Macro and the Macro
does not like using a filter.
For example,
1
2
2
3
1
4
2
3

Should only show at the end of the formula.
1
2
3
4

Any advice would be appreciated!



IF(A1=A2,"duplicate","ok")

Filter the Column.Select Duplicate and Delete the Row

Hardeep kanwar


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Formula to Delete Duplicates but keep one record

The formula I have using is =IF(COUNTIF($C$9:C9,C9)1,"a",1). Then I go
through and filter the "a". I delete all of the "a" and then remove the
filter. When I recorded this in the Macro it did not run properly on a new
spreadsheet. Any ideas why? Is there something I need to do differently?
I'm not familar with Visual Basic so I'm not sure what I did wrong. Thanks.

"Lost in Excel" wrote:

I am looking for a Formula that can delete all of the duplicates but keep one
record. I want the entire row to be deleted if it is a duplicate, and I do
not want to use a filter. I need this function for a Macro and the Macro
does not like using a filter.
For example,
1
2
2
3
1
4
2
3

Should only show at the end of the formula.
1
2
3
4

Any advice would be appreciated!

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 duplicates in a row LM Excel Worksheet Functions 3 July 8th 08 07:20 PM
Delete duplicates? WH99 Excel Discussion (Misc queries) 2 April 16th 08 04:41 PM
Delete duplicates? kk Excel Discussion (Misc queries) 2 March 14th 08 02:22 PM
Need to Color Record in Duplicates nirod Excel Worksheet Functions 0 October 24th 06 02:15 PM
find last record in macro and delete all after Sherife Excel Discussion (Misc queries) 3 September 18th 06 03:51 AM


All times are GMT +1. The time now is 03:25 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"