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: 10

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,921
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How is the font getting coloured?
 

Saurabhj

Active Member
Joined
Jun 6, 2020
Messages
423
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,921
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Yes but how? manually, by conditional formatting, or some other method?
 

stillg

New Member
Joined
Feb 1, 2021
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
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: 2
  • Test 850 1.jpg
    Test 850 1.jpg
    158.4 KB · Views: 2

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,921
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Can you answer my question?
 

stillg

New Member
Joined
Feb 1, 2021
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
The whole table is converted from a PDF file. And this color code appear when I enter inside the colors menu.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,921
Office Version
  1. 365
Platform
  1. Windows
In that case use the code supplied by Saurabhj but change "Sheet1" to "Table 1"
 

Watch MrExcel Video

Forum statistics

Threads
1,130,252
Messages
5,641,116
Members
417,194
Latest member
Excellent Excel

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
Top