Try this against a copy--just in case. It worked ok in minor testing.
Option Explicit
Sub testme()
Dim wks As Worksheet
Dim iRow As Long
Dim iCol As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim maxColsToCheck As Long
Dim myColorIndex As Long
myColorIndex = 3 'red
maxColsToCheck = 50
Set wks = Worksheets("sheet1")
With wks
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iRow = LastRow To FirstRow + 1 Step -1
If .Cells(iRow, "A").Value < .Cells(iRow - 1, "A").Value Then
'do nothing
Else
For iCol = 2 To maxColsToCheck
With .Cells(iRow - 1, iCol)
If UCase(.Value) = "O" Then
.Value = .Parent.Cells(iRow, iCol).Value
.Interior.ColorIndex _
= .Parent.Cells(iRow, iCol).Interior.ColorIndex
Else
If InStr(1, .Parent.Cells(iRow, iCol).Value, _
.Value, vbTextCompare) 0 Then
'do nothing, string already there
Else
.Value = .Value & "," _
& .Parent.Cells(iRow, iCol).Value
.Interior.ColorIndex = myColorIndex
End If
End If
End With
Next iCol
'delete that duplicate
.Rows(iRow).Delete
End If
Next iRow
End With
End Sub
Jen wrote:
If a row has a duplicate name and values have two different values to merge
the two and indicate a color in that cell, if "O" than take in other value
"Dave Peterson" wrote:
Yeah, it could be done, but I'm kind of confused over what the current rules
are.
Can you restate them?
Jen wrote:
We would need some type of indicater that will flag that there is two
different values in one cell that had a duplicate key. Coloring the cell or
something. The merging of the two in one cell can be easily missed by others.
Is there a way we can do this? Unfortunately we do not have a set precedence
for which value is more important so we will need to be flagged for additonal
cleanup in other databases that the information came from
<<snipped
--
Dave Peterson
|