I'm Lost... Bin? Delineate different processes with time samples
Assumed is that the ws name is "Process Data". Change to suit. Also assumed
is that the process names are in column B starting in B2 and that the
duration data are listed adjacent in column A.
Written in a hurry (just now) with minimal testing. Ensure you have a backup
copy of your data first:
Sub TestXYZ()
Dim ws As Worksheet
Dim coll As Collection
Dim r As Range, c As Range
Dim i As Integer, ii As Integer
Dim iii As Integer
Set ws = Sheets("Process Data")
Set coll = New Collection
Set r = ws.Range(ws.Cells(2, 2), _
ws.Cells(2, 2).End(xlDown))
On Error Resume Next
For Each c In r.Cells
coll.Add c.Value, c.Value
Next
On Error GoTo 0
Application.ScreenUpdating = False
iii = 1
For i = 1 To coll.Count
ws.Cells(1, i + 4).Value = coll(i)
ii = 1
For Each c In r.Cells
If c.Value = coll(i) Then
ii = ii + 1
iii = IIf(ii iii, ii, iii)
ws.Cells(ii, i + 4) = c(1, 0).Value
End If
Next
Next
Set r = ws.Range(ws.Cells(1, 4), ws.Cells(2, 4))
r(1).Value = "Process:"
r(2).Value = "Duration:"
r.Font.Bold = True
Set r = ws.Range(ws.Cells(1, 5), ws.Cells(iii, i + 3))
r.HorizontalAlignment = xlHAlignCenter
r.VerticalAlignment = xlVAlignCenter
r.Columns.AutoFit
With r.Rows(1)
.Font.Color = vbRed
.Font.Bold = True
End With
Application.ScreenUpdating = True
End Sub
Regards,
Greg
|