EDUCATED MONKEY
Board Regular
- Joined
- Jul 17, 2011
- Messages
- 218
Hi I thought posting this would stop other wasting time!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
The set up is office 2007 windows XP professional IE8<o></o>
Object of the exercise was to find duplicated data in a worksheet column <o></o>
So I headed of to the data tools and selected remove duplicates now here is the warning select the data NOT the column, if you select the column you will get random answers depending upon your last entry in that column<o></o>
Having got this to work I needed a method to tell me where the duplicates are and not just delete them so I opted for the conditional formatting, which despite leaving the system running for two days produced nothing just hangs then the only way back is control halt delete!<o></o>
So I devised a plan, first sort the data so that duplicated data would end up on consecutive rows, the I could simply compare the values and were they matched row after row then I changed the cell colour and I had the answer I was seeking two days earlier within a minuet. <o></o>
The code below is how I achieved this; I am not saying this is the best way just one way to get the job done<o></o>
The hope is that you will not waste as much time over it as I did trying to get the conditional formatting to work <o></o>
The set up is office 2007 windows XP professional IE8<o></o>
Object of the exercise was to find duplicated data in a worksheet column <o></o>
So I headed of to the data tools and selected remove duplicates now here is the warning select the data NOT the column, if you select the column you will get random answers depending upon your last entry in that column<o></o>
Having got this to work I needed a method to tell me where the duplicates are and not just delete them so I opted for the conditional formatting, which despite leaving the system running for two days produced nothing just hangs then the only way back is control halt delete!<o></o>
So I devised a plan, first sort the data so that duplicated data would end up on consecutive rows, the I could simply compare the values and were they matched row after row then I changed the cell colour and I had the answer I was seeking two days earlier within a minuet. <o></o>
The code below is how I achieved this; I am not saying this is the best way just one way to get the job done<o></o>
The hope is that you will not waste as much time over it as I did trying to get the conditional formatting to work <o></o>
Code:
Sub COlourDups()
'
' COlourDups Macro
'
' Keyboard Shortcut: Ctrl+c
'
Dim Mystring1 As String
Dim Mystring2 As String
Dim n As Long
'
ActiveWorkbook.Sheets("ISBN DATA BASE1").Activate
For n = 1 To 87674 'max number of rows to test
Mystring1 = Worksheets("ISBN DATA BASE1").Cells(n, 3).Value ' column C
Mystring2 = Worksheets("ISBN DATA BASE1").Cells(n + 1, 3).Value ' column C
If Mystring1 = Mystring2 Then
Worksheets("ISBN DATA BASE1").Cells(n, 3).Interior.Color = 16751103
Worksheets("ISBN DATA BASE1").Cells(n + 1, 3).Interior.Color = 16751103
End If
Next n
End Sub