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

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".
Hi & welcome to MrExcel.
How is the font getting coloured?
 
Upvote 0
Hi,

Use below code:

VBA Code:
Sub findTextColor()
Dim lastRow As Integer, rowno As Integer, colno As Integer

lastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

For rowno = 2 To lastRow
    For colno = 3 To 6
        If Sheets("Sheet1").Cells(rowno, colno).Font.ColorIndex = 5 Then
            Sheets("Sheet1").Cells(rowno, 7) = colno - 2
        End If
    Next
Next
End Sub
 
Upvote 0
Yes but how? manually, by conditional formatting, or some other method?
 
Upvote 0
Hello Saurabhj.
The script returns the following error. I uploaded pictures.
On the original file, I have total 850 rows.
 

Attachments

  • Test 850.jpg
    Test 850.jpg
    148.5 KB · Views: 5
  • Test 850 1.jpg
    Test 850 1.jpg
    158.4 KB · Views: 4
Upvote 0
Can you answer my question?
 
Upvote 0
The whole table is converted from a PDF file. And this color code appear when I enter inside the colors menu.
 
Upvote 0
In that case use the code supplied by Saurabhj but change "Sheet1" to "Table 1"
 
Upvote 0

Forum statistics

Threads
1,213,533
Messages
6,114,179
Members
448,554
Latest member
Gleisner2

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