I'm one of the people who won't open attachments. And I think you'll be able to
lots more if you try it yourself, too. Post back if you have trouble.
As for comments, just a couple.
I dimmed some varibles to represent the current worksheet (you can change the
name in the Set line:
Set curWks = Worksheets("sheet1")
I added a new worksheet.
Put some stuff in A1 and B1 (.resize(1,2) means make that original range
(.range("a1")) look like 1 row and two columns.
find the firstrow (2) assumes you have header on the worksheet
find the lastrow. I used column A. Started in A65536 and came up the column
until I hit a value.
Then sorted that data in A:B.
Then I worked down the list.
For iRow = FirstRow To LastRow
If .Cells(iRow, 2).Value <> .Cells(iRow - 1, "B").Value Then
oRow = oRow + 1
newWks.Cells(oRow, "A").Value = .Cells(iRow, "A").Value
newWks.Cells(oRow, "B").Value = .Cells(iRow, "B").Value
Else
newWks.Cells(oRow, "A").Value _
= newWks.Cells(oRow, "A").Value _
& ", " & .Cells(iRow, "A").Value
End If
Next iRow
if the value in row X is different from the value in row X-1, then write it out
to the new worksheet.
If they're the same, then plop the value at the end of the existing value.
Option Explicit
Sub testme()
Dim curWks As Worksheet
Dim newWks As Worksheet
Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long
Dim oRow As Long
Set curWks = Worksheets("sheet1")
Set newWks = Worksheets.Add
With newWks.Range("a1").Resize(1, 2)
.Value = Array("Tool", "User")
.Font.Bold = True
End With
With curWks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("a:b").Sort _
key1:=.Range("b1"), order1:=xlAscending, _
key2:=.Range("a1"), order2:=xlAscending, _
header:=xlYes, MatchCase:=False, Orientation:=xlSortRows
oRow = 1
For iRow = FirstRow To LastRow
If .Cells(iRow, 2).Value <> .Cells(iRow - 1, "B").Value Then
oRow = oRow + 1
newWks.Cells(oRow, "A").Value = .Cells(iRow, "A").Value
newWks.Cells(oRow, "B").Value = .Cells(iRow, "B").Value
Else
newWks.Cells(oRow, "A").Value _
= newWks.Cells(oRow, "A").Value _
& ", " & .Cells(iRow, "A").Value
End If
Next iRow
End With
End Sub