Hello again,
Tusharm said:
Don't know why Nate suggested a VBA solution.
I know, it's only vba, but I like it.
Seriously, it's effective, meaning accurate and returns the data in a flexible/preferred format (with the right code modifications) and won't alter your file size to much extent. Very functional, not too slow, seems very viable to me.
Beaumont said:
I am willing to use a VBA solution if necessary (did you really write all that code in such a short time?!) but I am unlikely to be able to adapt it to other slightly different situations. The code written seemed to do the first part of the task very well.
Nope, I used the recorder.
Well, keep this is as a last resort.
I guess one man's trash is another man's treasure... To each their reach.
Yeah, I missed the other part, and rereading it, I realize that I don't understand this:
This would be a great start. Even better would be if we could show how far ahead each student is ahead of the last, e.g if top student in x1 is 5% ahead of next student then this next student should appear 5 cells further down etc.
I've adjusted the code to populate column I with the percentage of each students score above that of the lowest scoring student in the group. The spacing thing threw me off, why would you want to correlate a percentage difference with actual cell spacing? In any case, here's the tweak:
<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> Sort_by_Grp2()
<SPAN style="color:green">' Kudos to John Walkenbach & J.G. Hussey from Coll. Sort Technique _
http://j-walk.com/ss/excel/tips/tip47.htm</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> cl <SPAN style="color:darkblue">As</SPAN> Range, cls <SPAN style="color:darkblue">As</SPAN> Range, ws <SPAN style="color:darkblue">As</SPAN> Worksheet
<SPAN style="color:darkblue">Dim</SPAN> i <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>, j <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Integer</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> Swap1, Swap2
<SPAN style="color:darkblue">Dim</SPAN> x1 <SPAN style="color:darkblue">As</SPAN> Collection, x2 <SPAN style="color:darkblue">As</SPAN> Collection, x3 <SPAN style="color:darkblue">As</SPAN> Collection, x4 <SPAN style="color:darkblue">As</SPAN> Collection
<SPAN style="color:darkblue">Dim</SPAN> x5 <SPAN style="color:darkblue">As</SPAN> Collection, x6 <SPAN style="color:darkblue">As</SPAN> Collection, x7 <SPAN style="color:darkblue">As</SPAN> Collection
<SPAN style="color:darkblue">Dim</SPAN> y1 <SPAN style="color:darkblue">As</SPAN> Collection, y2 <SPAN style="color:darkblue">As</SPAN> Collection, y3 <SPAN style="color:darkblue">As</SPAN> Collection, y4 <SPAN style="color:darkblue">As</SPAN> Collection
<SPAN style="color:darkblue">Dim</SPAN> y5 <SPAN style="color:darkblue">As</SPAN> Collection, y6 <SPAN style="color:darkblue">As</SPAN> Collection, y7 <SPAN style="color:darkblue">As</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> x1 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> x2 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> x3 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> x4 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> x5 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> x6 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> x7 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> y1 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> y2 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> y3 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> y4 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> y5 = <SPAN style="color:darkblue">New</SPAN> Collection: <SPAN style="color:darkblue">Set</SPAN> y6 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:darkblue">Set</SPAN> y7 = <SPAN style="color:darkblue">New</SPAN> Collection
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'****************************</SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">Set</SPAN> cls = Sheets(1).[a1:a350] <SPAN style="color:green">'Set Your Input Range</SPAN>
<SPAN style="color:green"><SPAN style="color:green"><SPAN style="color:green">'****************************</SPAN></SPAN></SPAN>
<SPAN style="color:darkblue">For</SPAN> <SPAN style="color:darkblue">Each</SPAN> cl <SPAN style="color:darkblue">In</SPAN> cls
<SPAN style="color:darkblue">Select</SPAN> <SPAN style="color:darkblue">Case</SPAN> cl(, 2).Value
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x1"
x1.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x2"
x2.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x3"
x3.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x4"
x4.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x5"
x5.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x6"
x6.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "x7"
x7.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y1"
y1.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y2"
y2.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y3"
y3.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y4"
y4.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y5"
y5.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y6"
y6.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">Case</SPAN> <SPAN style="color:darkblue">Is</SPAN> = "y7"
y7.Add Array(cl(, 3), cl)
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Select</SPAN>
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">Set</SPAN> cls = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x1.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x1.Count
<SPAN style="color:darkblue">If</SPAN> x1(i)(0) < x1(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x1(i)
Swap2 = x1(j)
x1.Add Swap1, before:=j
x1.Add Swap2, before:=i
x1.Remove i + 1
x1.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x2.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x2.Count
<SPAN style="color:darkblue">If</SPAN> x2(i)(0) < x2(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x2(i)
Swap2 = x2(j)
x2.Add Swap1, before:=j
x2.Add Swap2, before:=i
x2.Remove i + 1
x2.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x3.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x3.Count
<SPAN style="color:darkblue">If</SPAN> x3(i)(0) < x3(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x3(i)
Swap2 = x3(j)
x3.Add Swap1, before:=j
x3.Add Swap2, before:=i
x3.Remove i + 1
x3.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x4.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x4.Count
<SPAN style="color:darkblue">If</SPAN> x4(i)(0) < x4(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x4(i)
Swap2 = x4(j)
x4.Add Swap1, before:=j
x4.Add Swap2, before:=i
x4.Remove i + 1
x4.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x5.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x5.Count
<SPAN style="color:darkblue">If</SPAN> x5(i)(0) < x5(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x5(i)
Swap2 = x5(j)
x5.Add Swap1, before:=j
x5.Add Swap2, before:=i
x5.Remove i + 1
x5.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x6.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x6.Count
<SPAN style="color:darkblue">If</SPAN> x6(i)(0) < x6(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x6(i)
Swap2 = x6(j)
x6.Add Swap1, before:=j
x6.Add Swap2, before:=i
x6.Remove i + 1
x6.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x7.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> x7.Count
<SPAN style="color:darkblue">If</SPAN> x7(i)(0) < x7(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = x7(i)
Swap2 = x7(j)
x7.Add Swap1, before:=j
x7.Add Swap2, before:=i
x7.Remove i + 1
x7.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y1.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y1.Count
<SPAN style="color:darkblue">If</SPAN> y1(i)(0) < y1(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y1(i)
Swap2 = y1(j)
y1.Add Swap1, before:=j
y1.Add Swap2, before:=i
y1.Remove i + 1
y1.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y2.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y2.Count
<SPAN style="color:darkblue">If</SPAN> y2(i)(0) < y2(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y2(i)
Swap2 = y2(j)
y2.Add Swap1, before:=j
y2.Add Swap2, before:=i
y2.Remove i + 1
y2.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y3.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y3.Count
<SPAN style="color:darkblue">If</SPAN> y3(i)(0) < y3(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y3(i)
Swap2 = y3(j)
y3.Add Swap1, before:=j
y3.Add Swap2, before:=i
y3.Remove i + 1
y3.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y4.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y4.Count
<SPAN style="color:darkblue">If</SPAN> y4(i)(0) < y4(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y4(i)
Swap2 = y4(j)
y4.Add Swap1, before:=j
y4.Add Swap2, before:=i
y4.Remove i + 1
y4.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y5.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y5.Count
<SPAN style="color:darkblue">If</SPAN> y5(i)(0) < y5(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y5(i)
Swap2 = y5(j)
y5.Add Swap1, before:=j
y5.Add Swap2, before:=i
y5.Remove i + 1
y5.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y6.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y6.Count
<SPAN style="color:darkblue">If</SPAN> y6(i)(0) < y6(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y6(i)
Swap2 = y6(j)
y6.Add Swap1, before:=j
y6.Add Swap2, before:=i
y6.Remove i + 1
y6.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y7.Count - 1
<SPAN style="color:darkblue">For</SPAN> j = i + 1 <SPAN style="color:darkblue">To</SPAN> y7.Count
<SPAN style="color:darkblue">If</SPAN> y7(i)(0) < y7(j)(0) <SPAN style="color:darkblue">Then</SPAN>
Swap1 = y7(i)
Swap2 = y7(j)
y7.Add Swap1, before:=j
y7.Add Swap2, before:=i
y7.Remove i + 1
y7.Remove j + 1
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">If</SPAN>
<SPAN style="color:darkblue">Next</SPAN> j
<SPAN style="color:darkblue">Next</SPAN> i
Application.ScreenUpdating = <SPAN style="color:darkblue">False</SPAN>
<SPAN style="color:darkblue">Set</SPAN> ws = Sheets(2)
ws.[e:i].ClearContents
<SPAN style="color:darkblue">With</SPAN> ws.[e1:i1]
.Value = [{"Group","Score","","Name","% Above Last"}] <SPAN style="color:green">'Set Your Headers</SPAN>
.HorizontalAlignment = xlCenter
.Font.Bold = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x1.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x1" <SPAN style="color:green">'Pabel group on first</SPAN>
cl = x1(i)(0): cl(, 3) = x1(i)(1) <SPAN style="color:green">'Plant Score & Name</SPAN>
cl(, 4) = x1(i)(0) / x1(x1.Count)(0) - 1 <SPAN style="color:green">'Plant % Above Last</SPAN>
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x2.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x2"
cl = x2(i)(0): cl(, 3) = x2(i)(1)
cl(, 4) = x2(i)(0) / x2(x2.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x3.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x3"
cl = x3(i)(0): cl(, 3) = x3(i)(1)
cl(, 4) = x3(i)(0) / x3(x3.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x4.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x4"
cl = x4(i)(0): cl(, 3) = x4(i)(1)
cl(, 4) = x4(i)(0) / x4(x4.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x5.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x5"
cl = x5(i)(0): cl(, 3) = x5(i)(1)
cl(, 4) = x5(i)(0) / x5(x5.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x6.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x6"
cl = x6(i)(0): cl(, 3) = x6(i)(1)
cl(, 4) = x6(i)(0) / x6(x6.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> x7.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "x7"
cl = x7(i)(0): cl(, 3) = x7(i)(1)
cl(, 4) = x7(i)(0) / x7(x7.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y1.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y1"
cl = y1(i)(0): cl(, 3) = y1(i)(1)
cl(, 4) = y1(i)(0) / y1(y1.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y2.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y2"
cl = y2(i)(0): cl(, 3) = y2(i)(1)
cl(, 4) = y2(i)(0) / y2(y2.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y3.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y3"
cl = y3(i)(0): cl(, 3) = y3(i)(1)
cl(, 4) = y3(i)(0) / y3(y3.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y4.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y4"
cl = y4(i)(0): cl(, 3) = y4(i)(1)
cl(, 4) = y4(i)(0) / y4(y4.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y5.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y5"
cl = y5(i)(0): cl(, 3) = y5(i)(1)
cl(, 4) = y5(i)(0) / y5(y5.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y6.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y6"
cl = y6(i)(0): cl(, 3) = y6(i)(1)
cl(, 4) = y6(i)(0) / y6(y6.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
<SPAN style="color:darkblue">For</SPAN> i = 1 <SPAN style="color:darkblue">To</SPAN> y7.Count
<SPAN style="color:darkblue">Set</SPAN> cl = ws.[f65536].End(3)(2)
<SPAN style="color:darkblue">If</SPAN> i = 1 <SPAN style="color:darkblue">Then</SPAN> cl(, 0) = "y7"
cl = y7(i)(0): cl(, 3) = y7(i)(1)
cl(, 4) = y7(i)(0) / y7(y7.Count)(0) - 1
<SPAN style="color:darkblue">Next</SPAN>
ws.Range([i2], cl(, 4)).NumberFormat = "0.00%"
<SPAN style="color:darkblue">Set</SPAN> cl = <SPAN style="color:darkblue">Nothing</SPAN>
ws.[g:g].ColumnWidth = 3
ws.[e:f,h:i].EntireColumn.AutoFit
<SPAN style="color:darkblue">Set</SPAN> ws = <SPAN style="color:darkblue">Nothing</SPAN>
Application.ScreenUpdating = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">Set</SPAN> x1 = Nothing: <SPAN style="color:darkblue">Set</SPAN> x2 = Nothing: <SPAN style="color:darkblue">Set</SPAN> x3 = Nothing: <SPAN style="color:darkblue">Set</SPAN> x4 = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> x5 = Nothing: <SPAN style="color:darkblue">Set</SPAN> x6 = Nothing: <SPAN style="color:darkblue">Set</SPAN> x7 = Nothing: <SPAN style="color:darkblue">Set</SPAN> y1 = <SPAN style="color:darkblue">Nothing</SPAN>
<SPAN style="color:darkblue">Set</SPAN> y2 = Nothing: <SPAN style="color:darkblue">Set</SPAN> y3 = Nothing: <SPAN style="color:darkblue">Set</SPAN> y4 = Nothing: <SPAN style="color:darkblue">Set</SPAN> y5 = <SPAN style="color:darkblue">Nothing</SPAN></FONT>
<font face=Courier New><SPAN style="color:darkblue">Set</SPAN> y6 = Nothing: <SPAN style="color:darkblue">Set</SPAN> y7 = <SPAN style="color:darkblue">Nothing</SPAN></FONT>
<font face=Courier New><SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
This code is relatively flexible, you can change length of the list, vary group sizes, memborships and it should still fire. Have a good one eh.