Hi this is part 2 of my COUNTSAMPLE file. I have created an array. My goal is to loop through the array and place the SumProduct formula which does a count of CC From, CC To, CORRECTED. Column N, O, P reflects how the data should appear. It works for the first row only. I missing a counter of some sort. The Code is on the a separte tab. Can you help?
Sub CountCfCtCo()
Dim vs As Worksheet
Set vs = Worksheets("SAMPLED DATA")
Dim Rng As Range
Dim Eclm As Long
Dim erow As Long
Dim i As Long
i = 8
Dim mYaRRay As Variant
Dim Eid As Long
Eid = vs.Cells(i, 2)
Dim ExpD As Long
ExpD = vs.Cells(i, 6)
Dim erow2 As Long
Dim cnt As Long
With vs
erow = .Cells(.Rows.Count, 1).End(xlUp).Row
Eclm = .Cells(7, .Columns.Count).End(xlUp).Column
Set Rng = .Range(.Cells(8, "B"), .Cells(erow, Eclm))
End With
Debug.Print Rng.Address
mYaRRay = Rng.Value
Debug.Print mYaRRay(1, 1), mYaRRay(2, 1), mYaRRay(2, 2), mYaRRay(2, 3), mYaRRay(2, 4)
For Each cell In mYaRRay
If vs.Cells(i, 2) <> vs.Cells(i + 1, 2) And vs.Cells(i, 6) <> vs.Cells(i + 1, 6) Then
vs.Range(i, 14).Formula = " "
vs.Range(i, 15).Formula = " "
vs.Range(i, 16).Formula = " "
cnt = cnt + 1
End If
If vs.Cells(i, 2) = vs.Cells(i + 1, 2) And vs.Cells(i, 6) <> vs.Cells(i + 1, 6) Then
vs.Range(i, 14).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$3))"
vs.Range(i, 15).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$4))"
vs.Range(i, 16).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$5))"
cnt = cnt + 1
End If
If vs.Cells(i, 2) = vs.Cells(i + 1, 2) And vs.Cells(i, 6) = vs.Cells(i + 1, 6) Then
vs.Cells(i, 14).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$3))"
vs.Cells(i, 15).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$4))"
vs.Cells(i, 16).Formula = "=SUMPRODUCT((B:B=$D8)*(F:F=$G8)*(E:E=$E$5))"
cnt = cnt + 1
End If
Next
End Sub