• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Matching with colour

Hello,

I am now stuck at a problem.. Need your help...

In column A I have Question Number and 4 options..Correct answer is in green colour... I have extracted my answer... I need to match with that colour...
please help me on this
 

Attachments

  • Answer sheet.xlsx
    39.5 KB · Views: 7
I think the solution requires VBA. This is not great coding but might provide a starting point.
Code:
Sub TestColor()
Dim cell As Range
Dim I As Integer, J As Integer
Dim c As Double
    For Each cell In [A1:A60]
        For I = 1 To 4
            J = 12 + (I - 1) * 5
            c = cell.Characters(Start:=J, Length:=1).Font.Color
            If c = 4172854 Then
                cell.Offset(0, 4).Value = "Correct option is " & I
            End If
        Next I
    Next cell
End Sub
It relies on finding the numbers at specific location in each string and places any result it finds in column E.
 
Hi:

May be this function


Code:
Function colour(rng As Range) As String
Dim r$
c$ = rng.Text
For i& = 1 To VBA.Len(c)
If rng.Characters(i, 1).Font.Color = 4172854 Then r = r & VBA.Mid(c, i, 1)
Next
colour = Trim(Left(r, 1))
End Function

Thanks
 

Attachments

  • Answer sheet.xlsb
    29.8 KB · Views: 4
Back
Top