Find and copy duplicates to new worksheet
Hi Tom,
Your solution works nicely; many thanks. Thanks also for the coding
tips - duly noted!
Del.
On Oct 2, 3:05 pm, Tom Ogilvy
wrote:
A solution has been offered. Is there a problem.
--
Regards,
Tom Ogilvy
"Del_F" wrote:
okay, made some progress:
Sub FindDuplicates()
Dim check As String
Dim colName As String
Dim A As Integer
Dim count As Integer
colName = "B"
count = 1
Range(colName & 1).Select
'loop through first 100 rows
For A = 1 To 100
Range(colName & A).Activate
If ActiveCell.Value = check Then
ActiveCell.Font.Bold = True
ActiveCell.EntireRow.Copy
Destination:=Worksheets("Sheet2").Cells(count, 1)
count = count + 1
Else
End If
check = ActiveCell.Value
Next A
End Sub
Any tips on how to copy both the matched row and the row above (i.e.
the source of the 'check' value) would be welcome!
Many thanks.
On 2 Oct, 13:53, Del_F wrote:
Hi,
I have a macro to find and mark duplicated values in a sorted column
of data as follows:
Sub FindDuplicates()
Dim check As String
Dim colName As String
Dim A As Integer
colName = "B"
Range(colName & 1).Select
'loop through first 100 rows
For A = 1 To 100
Range(colName & A).Activate
If ActiveCell.Value = check Then
ActiveCell.Font.Bold = True
Else
End If
check = ActiveCell.Value
Next A
End Sub
I'd like to copy the values from the marked cells (and also the
matching value from the cell above, if possible) to a new worksheet.
I can get the first hit okay by adding this code to the loop:
ActiveCell.EntireRow.Copy
Sheets(2).Select
ActiveSheet.Paste
... but this breaks things - presumably because I lose the active
cell?
Any suggestions on how I should approach this?
many thanks,
Del.
|