View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default I'm Lost... Bin? Delineate different processes with time sam

William, I have changed the macro to obtain the duration times and process
names from columns X and Y respectively of sheet "Process Data". The results
will be copied to sheet "Chart Data" starting in A1. I have included a few
comments to assist you with understanding.

Sub TestXYZ()
Dim ws As Worksheet, ws2 As Worksheet
Dim coll As Collection
Dim r As Range, r2 As Range
Dim c As Range
Dim i As Integer, ii As Integer
Dim iii As Integer

Set ws = Sheets("Process Data")
Set ws2 = Sheets("Chart Data")
Set coll = New Collection
'Number 25 references column "Y" of ws
Set r = ws.Range(ws.Cells(2, 25), _
ws.Cells(2, 25).End(xlDown))
'See John Walkenbauch's site for following
'technique to create collection of unique items only
'http://www.j-walk.com/ss/excel/tips/tip47.htm
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
ws2.Cells(1, i + 1).Value = coll(i)
ii = 1
For Each c In r.Cells
If c.Value = coll(i) Then
ii = ii + 1
'iii records maximum length of list
iii = IIf(ii iii, ii, iii)
ws2.Cells(ii, i + 1) = c(1, 0).Value
End If
Next
Next
'Number 1 references column "A" of ws2
Set r = ws2.Range(ws2.Cells(1, 1), ws2.Cells(2, 1))
r(1).Value = "Process: "
r(2).Value = "Duration: "
'Number 2 references column "B" of ws2
'i = count of unique process names + 1
Set r2 = ws2.Range(ws2.Cells(1, 2), ws2.Cells(iii, i))
r2.HorizontalAlignment = xlHAlignCenter
r2.VerticalAlignment = xlVAlignCenter
ws2.Range(r, r2).Columns.AutoFit
With Union(r, r2.Rows(1))
.Font.Color = vbRed
.Font.Bold = True
End With
Application.ScreenUpdating = True
End Sub

P.S.
Thanks for your concern about my lab management program. If you read enough
of the thread you will know that I am (was) thoroughly p***ed off with my
employer. I did follow through and quit. Today, coincidentally, was the first
day with the new company. The lab manager (former company) gave notice one
week after I did. The place is now pretty much gutted for real experience.
And there is serious question as to their viability. I can't imagine why
someone would think that <g.

Regards,
Greg