[B][color=Royalblue]Sub[/color][/B] a1075737e()
[i][color=seagreen]'https://www.mrexcel.com/forum/excel-questions/1075737-auto-colour-based-answer-key.html[/color][/i]
[B][color=Royalblue]Dim[/color][/B] r [B][color=Royalblue]As[/color][/B] Range, s [B][color=Royalblue]As[/color][/B] [B][color=Royalblue]String[/color][/B]
[B][color=Royalblue]Dim[/color][/B] i [B][color=Royalblue]As[/color][/B] [B][color=Royalblue]Long[/color][/B], j [B][color=Royalblue]As[/color][/B] [B][color=Royalblue]Long[/color][/B], x [B][color=Royalblue]As[/color][/B] [B][color=Royalblue]Long[/color][/B], z [B][color=Royalblue]As[/color][/B] [B][color=Royalblue]Long[/color][/B]
[B][color=Royalblue]Dim[/color][/B] va, vb, ac
Application.ScreenUpdating = [B][color=Royalblue]False[/color][/B]
Range([color=brown]"F3:I"[/color] & Cells(Rows.count, [color=brown]"E"[/color]).[B][color=Royalblue]End[/color][/B](xlUp).row).Interior.Color = xlNone
[B][color=Royalblue]For[/color][/B] [B][color=Royalblue]Each[/color][/B] r [B][color=Royalblue]In[/color][/B] Range([color=brown]"E3"[/color], Cells(Rows.count, [color=brown]"E"[/color]).[B][color=Royalblue]End[/color][/B](xlUp))
s = Trim(r)
[B][color=Royalblue]If[/color][/B] s [B][color=Royalblue]Like[/color][/B] [color=brown]"[A-D]"[/color] [B][color=Royalblue]Then[/color][/B]
x = r.row
Range(s & x).Offset([color=crimson]0[/color], [color=crimson]5[/color]).Interior.Color = vbGreen
va = Range(Cells(x, [color=brown]"F"[/color]), Cells(x, [color=brown]"I"[/color]))
[B][color=Royalblue]ReDim[/color][/B] vb([color=crimson]1[/color] [B][color=Royalblue]To[/color][/B] [color=crimson]1[/color], [color=crimson]1[/color] [B][color=Royalblue]To[/color][/B] UBound(va, [color=crimson]2[/color]))
j = [color=crimson]2[/color]
[B][color=Royalblue]For[/color][/B] i = [color=crimson]1[/color] [B][color=Royalblue]To[/color][/B] UBound(vb, [color=crimson]2[/color])
z = Range(s & [color=brown]"1"[/color]).Column
[B][color=Royalblue]If[/color][/B] z = i [B][color=Royalblue]Then[/color][/B]
vb([color=crimson]1[/color], [color=crimson]1[/color]) = va([color=crimson]1[/color], i)
[B][color=Royalblue]Else[/color][/B]
vb([color=crimson]1[/color], j) = va([color=crimson]1[/color], i)
j = j + [color=crimson]1[/color]
[B][color=Royalblue]End[/color][/B] [B][color=Royalblue]If[/color][/B]
[B][color=Royalblue]Next[/color][/B]
Range([color=brown]"K"[/color] & x) = Application.Index(vb, , [color=crimson]1[/color])
Range([color=brown]"M"[/color] & x) = Application.Index(vb, , [color=crimson]2[/color])
Range([color=brown]"O"[/color] & x) = Application.Index(vb, , [color=crimson]3[/color])
Range([color=brown]"Q"[/color] & x) = Application.Index(vb, , [color=crimson]4[/color])
[B][color=Royalblue]End[/color][/B] [B][color=Royalblue]If[/color][/B]
[B][color=Royalblue]Next[/color][/B]
Application.ScreenUpdating = [B][color=Royalblue]True[/color][/B]
[B][color=Royalblue]End[/color][/B] [B][color=Royalblue]Sub[/color][/B]