View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Multiple Countif - i,j,l counters probably mixed up

In that case then, here is a macro that I think does what you asked for...

Sub PoStatus()
Dim X As Long, Y As Long
Dim Data As Variant
Dim PoData() As Variant
Dim LastRow As Long
Dim MaxCrit As Long
Dim MaxProjects As Long
Dim UniqueProjectNames As New Collection
Const DataStartRow As Long = 2
With Worksheets("Summary")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Data = .Range("A" & DataStartRow & ":C" & LastRow)
On Error Resume Next
For X = DataStartRow To LastRow
UniqueProjectNames.Add .Cells(X, "A").Value, .Cells(X, "A").Value
Next
On Error GoTo 0
MaxCrit = WorksheetFunction.Max(.Range("B:B"))
MaxProjects = UniqueProjectNames.Count
ReDim PoData(1 To MaxProjects, 1 To MaxCrit + 1)
For X = 1 To MaxProjects
PoData(X, 1) = UniqueProjectNames(X)
Next
For Y = 1 To MaxProjects
For X = 2 To LastRow
If PoData(Y, 1) = .Cells(X, "A") Then
PoData(Y, .Cells(X, "B") + 1) = PoData(Y, .Cells(X, "B") + 1) + 1
End If
Next
Next
End With
With Worksheets("PoStatus")
.Range("A1").Value = "Project"
For X = 1 To MaxCrit
.Cells(1, X + 1).Value = "Crit" & X
Next
.Range("A2").Resize(MaxProjects, MaxCrit + 1) = PoData
End With
End Sub

--
Rick (MVP - Excel)


"u473" wrote in message
...
Thank you, I know how handle Pivot table, in this case I want to
master VBA logic
J.P.