Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default RemoveDuplicates not removing all duplicate entries

I can't see what is failing in this macro to remove all duplicates.
I always end up with one duplicate left over?
All help is appreciated.

'======
Sub RemoveDups()
ActiveSheet.Unprotect "2000"
Application.ScreenUpdating = False

Dim Sh3LastRow
Dim Sh3LastCol

With Sheets("Order Specs")
Sh3LastRow = .Cells(Rows.Count, "A").End(xlUp).row
Sh3LastCol = Range("A2").Cells(1, .Columns.Count).End(xlToLeft).Column
End With

ActiveSheet.Range("A2:K" & Sh3LastRow).RemoveDuplicates
Columns:=Array(1, 2), Header:=xlYes
Range("A2").Activate
'ActiveSheet.Protect "2000"
Application.ScreenUpdating = True
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default RemoveDuplicates not removing all duplicate entries

It is always due to the cells not containing exactly the same data.
Sometimes it is a space or tab at the beginninhgor end of the data.
sometimes it is a mis-spelled word. Other times it is the letter o instead
of the digit 0. 1's instead of l's. Maybe an extra space between words.
Look and eventualy you find the mis-match.

One way of comparing is copy both cells to notepad. Put each piece of data
on a seperate line and look close at the two lines of data.

"Rick S." wrote:

I can't see what is failing in this macro to remove all duplicates.
I always end up with one duplicate left over?
All help is appreciated.

'======
Sub RemoveDups()
ActiveSheet.Unprotect "2000"
Application.ScreenUpdating = False

Dim Sh3LastRow
Dim Sh3LastCol

With Sheets("Order Specs")
Sh3LastRow = .Cells(Rows.Count, "A").End(xlUp).row
Sh3LastCol = Range("A2").Cells(1, .Columns.Count).End(xlToLeft).Column
End With

ActiveSheet.Range("A2:K" & Sh3LastRow).RemoveDuplicates
Columns:=Array(1, 2), Header:=xlYes
Range("A2").Activate
'ActiveSheet.Protect "2000"
Application.ScreenUpdating = True
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default RemoveDuplicates not removing all duplicate entries

The strange thing is, I can copy data from one row into another row, two
times, creating three total copies and the code will only remove one of the
copies?

I just can't figure out why?
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007



"Joel" wrote:

It is always due to the cells not containing exactly the same data.
Sometimes it is a space or tab at the beginninhgor end of the data.
sometimes it is a mis-spelled word. Other times it is the letter o instead
of the digit 0. 1's instead of l's. Maybe an extra space between words.
Look and eventualy you find the mis-match.

One way of comparing is copy both cells to notepad. Put each piece of data
on a seperate line and look close at the two lines of data.

"Rick S." wrote:

I can't see what is failing in this macro to remove all duplicates.
I always end up with one duplicate left over?
All help is appreciated.

'======
Sub RemoveDups()
ActiveSheet.Unprotect "2000"
Application.ScreenUpdating = False

Dim Sh3LastRow
Dim Sh3LastCol

With Sheets("Order Specs")
Sh3LastRow = .Cells(Rows.Count, "A").End(xlUp).row
Sh3LastCol = Range("A2").Cells(1, .Columns.Count).End(xlToLeft).Column
End With

ActiveSheet.Range("A2:K" & Sh3LastRow).RemoveDuplicates
Columns:=Array(1, 2), Header:=xlYes
Range("A2").Activate
'ActiveSheet.Protect "2000"
Application.ScreenUpdating = True
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default RemoveDuplicates not removing all duplicate entries

I figured this out!
This was the offending code section: (One string)
ActiveSheet.Range("A1:K" & Sh3LastRow).RemoveDuplicates Columns:=Array(1,
2), Header:=xlYes

'======
Sub RemoveDups()
ActiveSheet.Unprotect "2000"
Application.ScreenUpdating = False

Dim Sh3LastRow
Dim Sh3LastCol

With Sheets("Order Specs")
Sh3LastRow = .Cells(Rows.Count, "A").End(xlUp).row
End With

ActiveSheet.Range("A1:K" & Sh3LastRow).RemoveDuplicates
Columns:=Array(1, 2), Header:=xlYes
Range("A2").Activate
'ActiveSheet.Protect "2000"
Application.ScreenUpdating = True
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007



"Rick S." wrote:

I can't see what is failing in this macro to remove all duplicates.
I always end up with one duplicate left over?
All help is appreciated.

'======
Sub RemoveDups()
ActiveSheet.Unprotect "2000"
Application.ScreenUpdating = False

Dim Sh3LastRow
Dim Sh3LastCol

With Sheets("Order Specs")
Sh3LastRow = .Cells(Rows.Count, "A").End(xlUp).row
Sh3LastCol = Range("A2").Cells(1, .Columns.Count).End(xlToLeft).Column
End With

ActiveSheet.Range("A2:K" & Sh3LastRow).RemoveDuplicates
Columns:=Array(1, 2), Header:=xlYes
Range("A2").Activate
'ActiveSheet.Protect "2000"
Application.ScreenUpdating = True
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007

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 duplicate entries Roger Bell New Users to Excel 2 June 23rd 07 10:20 AM
Removing duplicate entries katiek648 Excel Discussion (Misc queries) 2 August 4th 06 06:56 PM
removing duplicate entries armagan Excel Discussion (Misc queries) 1 June 12th 06 05:42 PM
Removing duplicate entries. dh01uk Excel Discussion (Misc queries) 2 January 13th 06 03:51 PM
Removing duplicate entries Billy[_3_] Excel Programming 7 January 9th 04 07:47 AM


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