Sub Spacle(): Dim wm As Worksheet, wt As Worksheet, r As Long, c As Long, i As Long, j As Long, k As Long
Dim Mgr As String, Cmp As String, Cll As String, Knd As String, Hold As String, Fold As String
Set wm = ActiveWorkbook.Sheets("Sheet1"): 'Master
r = wm.Rows.Find("*", , , , xlByRows, xlPrevious).Row: k = 2
Set wt = ActiveWorkbook.Sheets("Sheet2") 'Tally
c = wm.Columns.Find("*", , , , xlByColumns, xlPrevious).Column
wt.Range("A1") = "Manager": wt.Range("B1") = "Company": wt.Range("C1") = "Call Date"
wt.Range("D1") = "Kind of Call": wt.Columns.AutoFit
For i = 2 To r
Mgr = wm.Range("A" & i): Cmp = wm.Range("B" & i)
For j = 3 To c
If Cells(i, j) <> "" Then
Cll = wm.Cells(i, j): Knd = wm.Cells(1, j): Exit For
Else: Cll = "": Knd = "": End If: Next j
With wt
.Cells(k, 1) = Mgr: .Cells(k, 2) = Cmp: .Cells(k, 3) = Cll: .Cells(k, 4) = Knd: k = k + 1
End With
Next i
wt.Cells.Sort Key1:=wt.Range("C1"), Header:=xlYes
r = wt.Rows.Find("*", , , , xlByRows, xlPrevious).Row: i = 2: j = 2: k = 2
For i = 2 To r - 1
Hold = Trim(wt.Range("A" & i)) & Trim(wt.Range("B" & i))
For j = i + 1 To r
If j > r Then GoTo GetNext
Fold = Trim(wt.Range("A" & j)) & Trim(wt.Range("B" & j))
If Hold = Fold Then
Cll = wt.Cells(i, 3): Knd = wt.Cells(i, 4)
If InStr(1, Cll, wt.Cells(j, 3)) = 0 Then wt.Cells(i, 3) = Cll & ", " & wt.Cells(j, 3)
If InStr(1, Knd, wt.Cells(j, 4)) = 0 Then wt.Cells(i, 4) = Knd & ", " & wt.Cells(j, 4)
wt.Cells(j, 1).EntireRow.Delete Shift:=xlUp: j = j - 1: r = r - 1
End If: Next j
GetNext: Next i: wt.Columns.AutoFit: End Sub
Directions for running the routine(s) just supplied
Bookmarks