Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Removing Both Duplicates from a list

I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do this
with Remove Duplicates as it still leaves me with one of each number.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Removing Both Duplicates from a list

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tim" wrote in message
...
I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do
this
with Remove Duplicates as it still leaves me with one of each number.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,718
Default Removing Both Duplicates from a list

"List" is a defined name range (no quotes)

=IF(ISERR(SMALL(IF(COUNTIF(List,List)=1,ROW(INDIRE CT("1:"&ROWS(List)))),ROWS($1:1))),"",INDEX(List,S MALL(IF(COUNTIF(List,List)=1,ROW(INDIRECT("1:"&ROW S(List)))),ROWS($1:1))))

ctrl+shift+enter, not just enter
copy down as far as needed


"tim" wrote:

I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do this
with Remove Duplicates as it still leaves me with one of each number.

  #4   Report Post  
Posted to microsoft.public.excel.misc
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Removing Both Duplicates from a list

Also Is this something maybe Microsoft can work into the tool on the next
release of Office or a patch?

Thanks both of you that replied it has been driving me nuts all morning.

"Teethless mama" wrote:

"List" is a defined name range (no quotes)

=IF(ISERR(SMALL(IF(COUNTIF(List,List)=1,ROW(INDIRE CT("1:"&ROWS(List)))),ROWS($1:1))),"",INDEX(List,S MALL(IF(COUNTIF(List,List)=1,ROW(INDIRECT("1:"&ROW S(List)))),ROWS($1:1))))

ctrl+shift+enter, not just enter
copy down as far as needed


"tim" wrote:

I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do this
with Remove Duplicates as it still leaves me with one of each number.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default Removing Both Duplicates from a list


Works great. If there are duplicates, it removes both. How can i do the same
thing except leave just one of the duplicates
"Don Guillett" wrote:

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tim" wrote in message
...
I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do
this
with Remove Duplicates as it still leaves me with one of each number.





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Removing Both Duplicates from a list

Try this For ALL , IF sorted

Sub removealldupsAll()
mc = "a"
lr = Cells(Rows.Count, mc).End(xlUp).Row
Set mrng = Range(Cells(2, mc), Cells(lr, mc))
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
Count = Application.CountIf(mrng, Cells(i, mc))
If Count 1 Then Rows(i - Count + 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tim" wrote in message
...
I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do
this
with Remove Duplicates as it still leaves me with one of each number.


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default Removing Both Duplicates from a list

Use a Pivot table. This would show only 1 row with a count of how many dups
there are

"Don Guillett" wrote:

Try this For ALL , IF sorted

Sub removealldupsAll()
mc = "a"
lr = Cells(Rows.Count, mc).End(xlUp).Row
Set mrng = Range(Cells(2, mc), Cells(lr, mc))
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
Count = Application.CountIf(mrng, Cells(i, mc))
If Count 1 Then Rows(i - Count + 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tim" wrote in message
...
I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do
this
with Remove Duplicates as it still leaves me with one of each number.



  #9   Report Post  
Posted to microsoft.public.excel.misc
jd jd is offline
external usenet poster
 
Posts: 91
Default Removing Both Duplicates from a list

Hi Don -

This is EXACTLY what I need - but please forgive the noob question: where
exactly do I enter this equation?

Thanks,

JD

"Don Guillett" wrote:

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel


  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Removing Both Duplicates from a list

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

JD wrote:

Hi Don -

This is EXACTLY what I need - but please forgive the noob question: where
exactly do I enter this equation?

Thanks,

JD

"Don Guillett" wrote:

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.misc
jd jd is offline
external usenet poster
 
Posts: 91
Default Removing Both Duplicates from a list

Thank you Dave - I opened up the Macro dialogue and it wouldn't let me paste
the code into it, so I figured I was on the wrong track. I'll take a look at
these and give it another shot. Thanks again.

"Dave Peterson" wrote:

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

JD wrote:

Hi Don -

This is EXACTLY what I need - but please forgive the noob question: where
exactly do I enter this equation?

Thanks,

JD

"Don Guillett" wrote:

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel


--

Dave Peterson

  #12   Report Post  
Posted to microsoft.public.excel.misc
jd jd is offline
external usenet poster
 
Posts: 91
Default Removing Both Duplicates from a list

Thanks to you guys, I'm more knowledgeable on macros AND I've been able to
delete the duplicates. I thought I'd seen some data in triplicate or worse
(4x) but now it seems that it's gone. Is that just me, or does your code
delete all 2 OR MORE instances of data?

Thanks again!!

"Don Guillett" wrote:

try this idea. Works for TWO dups as you posted

Sub removeALLdups()
mc = "a"
For i = Cells(Rows.Count, mc).End(xlUp).Row To 2 Step -1
If Cells(i - 1, mc) = Cells(i, mc) Then Rows(i - 1 & ":" & i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"tim" wrote in message
...
I have a list that i need to remove all Duplicates, if I find any,

example
List
1
1
2
3
3
4
5
5

Goal
2
4


Not sure how to do this, I'm on office 2007 and I dont see a way to do
this
with Remove Duplicates as it still leaves me with one of each number.



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
Removing duplicates from a list of addresses bakerman Excel Discussion (Misc queries) 1 December 6th 07 10:56 PM
merge list while removing duplicates stef Excel Worksheet Functions 1 October 14th 06 07:52 PM
merge list while removing duplicates stef Excel Discussion (Misc queries) 0 October 13th 06 10:23 PM
removing duplicates from a list aleccamp Excel Discussion (Misc queries) 4 November 20th 05 03:22 AM
Removing Duplicates from a list JohnGuts Excel Worksheet Functions 5 August 14th 05 01:37 AM


All times are GMT +1. The time now is 09:58 AM.

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"