Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Staff Locations Roles
- 1 Location1 Role1
- 1 Location2 Role1
- 2 Location2 Role2
- 3 Location3 Role3
- 3 Location3 Role4
- Staff Locations Roles
- 1 Location1, Location2 Role1
- 2 Location2 Role2
- 3 Location3 Role3
- 3 Location3 Role4
- Sub Sort_Duplicates()
- Dim lngRow, lngRow2 As Long
- With ActiveSheet
- Dim flag As Integer: flag = 0
- Dim i As Integer
- Dim columnToMatch As Integer: columnToMatch = 1
- Dim column2ToMatch As Integer: column2ToMatch = 3
- Dim columnToConcatenate As Integer: columnToConcatenate = 2
- lngRow = .Cells(538537, columnToMatch).End(xlUp).Row
- .Cells(columnToMatch).CurrentRegion.Sort key1:=.Cells(columnToMatch), Header:=xlYes
- Do
- If .Cells(lngRow, columnToMatch) = .Cells(lngRow - 1, columnToMatch) Then
- 'flag = 1
- i = 1
- lngRow2 = lngRow
- Do While Cells(lngRow2, columnToMatch) = .Cells(lngRow2 - i, columnToMatch)
- If .Cells(lngRow2, column2ToMatch) = .Cells(lngRow2 - i, column2ToMatch) Then
- .Cells(lngRow2, columnToConcatenate) = .Cells(lngRow2, columnToConcatenate) & ", " & .Cells(lngRow2 - i, columnToConcatenate)
- .Rows(lngRow2 - i).Delete
- End If
- i = i + 1
- Loop
- lngRow2 = lngRow2 - 1
- End If
- ' If flag = 1 Then
- ' lngRow = lngRow2
- ' flag = 0
- ' Else
- lngRow = lngRow - 1
- 'End If
- Loop Until lngRow = 1
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement