How to set specific value if font is colored

stillg

New Member
Joined
Feb 1, 2021
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
Hello.
I need some help.
I have a test with 850 questions. Each row consists of starting from row 3 /number of the question (A3), the question itself(B3), Answer 1(C3),Answer 2(D3), Answer 3(E3), Answer 4(F3), Correct answer (G3).
The right answer among all 4 available answers is colored in BRG(0.0.255) Blue.
If the right answer is Answer 3/ colored in BRG(0.0.255) Blue/ - to appear 3 in Correct answer column G3.
If the right answer is Answer 4/ colored in BRG(0.0.255) Blue/ - to appear 4 in Correct answer column G3.
So I can apply this condition to all 850 questions.

Thank to all.
 

Attachments

  • Test 850.jpg
    Test 850.jpg
    163.5 KB · Views: 13
Thanks for that, not sure whether it's something to do with the conversion from pdf, or the unicode characters, but try this
VBA Code:
Sub stillg()
   Dim r As Long, c As Long, i As Long
   Dim Flg As Boolean
   
   For r = 3 To Range("A" & Rows.Count).End(xlUp).Row
      Flg = False
      For c = 3 To 6
         For i = 1 To Len(Cells(r, c))
            If Cells(r, c).Characters(i, 1).Font.Color = vbBlue Then
               Range("G" & r).Value = c - 2
               Flg = True
               Exit For
            End If
         Next i
         If Flg Then Exit For
      Next c
   Next r
End Sub
It may take a couple of minutes.
 
Upvote 0
Solution

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Thanks for that, not sure whether it's something to do with the conversion from pdf, or the unicode characters, but try this
VBA Code:
Sub stillg()
   Dim r As Long, c As Long, i As Long
   Dim Flg As Boolean
  
   For r = 3 To Range("A" & Rows.Count).End(xlUp).Row
      Flg = False
      For c = 3 To 6
         For i = 1 To Len(Cells(r, c))
            If Cells(r, c).Characters(i, 1).Font.Color = vbBlue Then
               Range("G" & r).Value = c - 2
               Flg = True
               Exit For
            End If
         Next i
         If Flg Then Exit For
      Next c
   Next r
End Sub
It may take a couple of minutes
 
Upvote 0
Thanks for that, not sure whether it's something to do with the conversion from pdf, or the unicode characters, but try this
VBA Code:
Sub stillg()
   Dim r As Long, c As Long, i As Long
   Dim Flg As Boolean
  
   For r = 3 To Range("A" & Rows.Count).End(xlUp).Row
      Flg = False
      For c = 3 To 6
         For i = 1 To Len(Cells(r, c))
            If Cells(r, c).Characters(i, 1).Font.Color = vbBlue Then
               Range("G" & r).Value = c - 2
               Flg = True
               Exit For
            End If
         Next i
         If Flg Then Exit For
      Next c
   Next r
End Sub
It may take a couple of minutes.
Work like a charm.
Thank You very much.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

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