Auto Colour based on answer key

bushidowarrior

Board Regular
Joined
Jun 27, 2011
Messages
84
Office Version
  1. 2019
Platform
  1. Windows
Hello All,

I have this table below. As you can see in the KEY column, is has the correct answer. In this case it is C.

Is there a was to make "WHAT" the correct answer highlight in GREEN?

And for the next row it would be D (They're)




i2amBDn.png



I would really appreciate it.

I have over 100 questions, hence I would like to automate this process a little.

Thank you.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If you've tried the last code (post #10 ) & still didn,t work then maybe there are some typos in your data like a trailing space.
If that is the case then I could modify the macro to handle the typos.
 
Upvote 0
If you've tried the last code (post #10 ) & still didn,t work then maybe there are some typos in your data like a trailing space.
If that is the case then I could modify the macro to handle the typos.

okay. I am not sure what is going on. But I am using your first code just to get it working.

Y291Opl.png
 
Upvote 0
Try this, KEY in col E not A:
Code:
Sub a1075737a()
'https://www.mrexcel.com/forum/excel-questions/1075737-auto-colour-based-answer-key.html
Dim r As Range
For Each r In Range("E2", Cells(Rows.count, "E").End(xlUp))
If Trim(r) Like "[A-D]" Then
Range(r & r.row).Offset(0, 5).Interior.Color = vbGreen
End If
Next
 
Upvote 0
Try this, KEY in col E not A:
Code:
Sub a1075737a()
'https://www.mrexcel.com/forum/excel-questions/1075737-auto-colour-based-answer-key.html
Dim r As Range
For Each r In Range("E2", Cells(Rows.count, "E").End(xlUp))
If Trim(r) Like "[A-D]" Then
Range(r & r.row).Offset(0, 5).Interior.Color = vbGreen
End If
Next


I gave it a god an nothing happened.

Code:
Sub a1075737a()
'https://www.mrexcel.com/forum/excel-questions/1075737-auto-colour-based-answer-key.html
Dim r As Range
For Each r In Range("E2", Cells(Rows.Count, "E").End(xlUp))
If Trim(r) Like "[A-D]" Then
Range(r & r.Row).Offset(0, 5).Interior.Color = vbGreen
End If
Next
End Sub
 
Last edited:
Upvote 0
The data should be in col E to I, like your image in post #3 .

Excel 2007 32 bit
[Table="width:, class:head"][tr=bgcolor:#008B8B][th] [/th][th]
E
[/th][th]
F
[/th][th]
G
[/th][th]
H
[/th][th]
I
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#008B8B]
1
[/td][td]key[/td][td]A[/td][td]B[/td][td]C[/td][td]D[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#008B8B]
2
[/td][td]C[/td][td][/td][td][/td][td=bgcolor:#00FF00][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#008B8B]
3
[/td][td]D[/td][td][/td][td][/td][td][/td][td=bgcolor:#00FF00][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#008B8B]
4
[/td][td]A[/td][td=bgcolor:#00FF00][/td][td][/td][td][/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet3[/td][/tr][/table]
 
Upvote 0
Yes, you are right.. Perfect, Thank you...

When I try to do it on my normal sheet. I get this message. I am not sure why it works on one sheet but not the other. Everything is identical between both sheets.

DQBWIA7.jpg
 
Upvote 0
Hm, not sure why that happened.
You put the code in normal module not in sheet module, right?
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top