[COLOR="Navy"]Sub[/COLOR] MG20Jul15
'[COLOR="Green"][B]forum3[/B][/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Q [COLOR="Navy"]As[/COLOR] Variant, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] K [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]With[/COLOR] Sheets("Data")
[COLOR="Navy"]Set[/COLOR] Rng = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]If[/COLOR] Not .Exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
ReDim nray(1 To 41, 1 To 2)
[COLOR="Navy"]For[/COLOR] n = 3 To UBound(nray, 1)
nray(n, 1) = IIf(UCase(Dn.Offset(, n - 2).Value) = "Y", 1, 0)
[COLOR="Navy"]If[/COLOR] UCase(Dn.Offset(, n - 2).Value) = "Y" Or UCase(Dn.Offset(, n - 2).Value) = "N" [COLOR="Navy"]Then[/COLOR]
nray(n, 2) = 1
[COLOR="Navy"]Else[/COLOR]
nray(n, 2) = 0
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
.Item(Dn.Value) = Array(nray, 1)
[COLOR="Navy"]Else[/COLOR]
Q = .Item(Dn.Value)
[COLOR="Navy"]For[/COLOR] n = 3 To UBound(Q(0))
Q(0)(n, 1) = Q(0)(n, 1) + IIf(UCase(Dn.Offset(, n - 2).Value) = "Y", 1, 0)
[COLOR="Navy"]If[/COLOR] UCase(Dn.Offset(, n - 2).Value) = "Y" Or UCase(Dn.Offset(, n - 2).Value) = "N" [COLOR="Navy"]Then[/COLOR]
Q(0)(n, 2) = Q(0)(n, 2) + 1
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
Q(1) = Q(1) + 1
.Item(Dn.Value) = Q
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]Dim[/COLOR] t, tt
ReDim ray(1 To .Count + 1, 1 To 41)
[COLOR="Navy"]For[/COLOR] ac = 1 To UBound(ray, 2)
[COLOR="Navy"]If[/COLOR] ac = 2 [COLOR="Navy"]Then[/COLOR]
ray(1, ac) = "Count of Audits"
[COLOR="Navy"]ElseIf[/COLOR] ac > 2 [COLOR="Navy"]Then[/COLOR]
ray(1, ac) = Rng(1).Offset(-1, ac - 2)
[COLOR="Navy"]Else[/COLOR]
ray(1, ac) = Rng(1).Offset(-1, ac - 1)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] ac
c = 1
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
c = c + 1
ray(c, 1) = K
ray(c, 2) = .Item(K)(1)
[COLOR="Navy"]For[/COLOR] ac = 3 To UBound(ray, 2)
[COLOR="Navy"]If[/COLOR] .Item(K)(0)(ac, 1) = 0 [COLOR="Navy"]Then[/COLOR]
ray(c, ac) = 0
[COLOR="Navy"]Else[/COLOR]
ray(c, ac) = Format(.Item(K)(0)(ac, 1) / .Item(K)(0)(ac, 2), "0%")
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]If[/COLOR] ray(c, ac) = "0%" [COLOR="Navy"]Then[/COLOR] ray(c, ac).NumberFormat = "0"
[COLOR="Navy"]Next[/COLOR] ac
[COLOR="Navy"]Next[/COLOR] K
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]With[/COLOR] Sheets("Results").Range("A1").Resize(c, UBound(ray, 2))
.Parent.Cells.NumberFormat = "general"
.Value = ray
.Borders.Weight = 2
.Parent.Rows(1).WrapText = True
.Rows.AutoFit
.Columns.AutoFit
[COLOR="Navy"]End[/COLOR] With
MsgBox "Code Run"
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]