Hi, I'm writing a function in excel that is a string converter. Essentially it takes information in a given set of cells and then encrypts them into a code.

So F2 = StringConv(A2,B2,C2,D2,E2) would return "12345" depending on cells A2 through E2.

I have it set up in such a way that if the data enter isn't valid it would return a question mark where the invalid data is.

So if there is bad data in B2, then F2 = StringConv(A2,B2,C2,D2,E2) would return "1?345"

What I want to do now is add conditional formatting into the function. So the function would read its own output and change the font to Bold and Red.

Function StringConv(Type As String, Class As String, p3 As String, p4 As String, Optional p5 As String, Optional p6 As String, Optional p7 As String) As String

Dim OutType As Integer
Dim OutClass As Integer


Select Case Type
'LINE
Case "L"
OutType = "1"
OutClass = Classifier(In_Class)
OutLine = LineCoding(p3, p4, p5, p6, p7)
StringConv = ""
StringConv = OutType + OutClass + OutLine
GoTo CodingEnd

CodingEnd:
End Function

Okay so I've emmitted a lot of the code because of confidentiallity reasons, but this should suffice. There are a few more Cases but they are set up in the exact same fashion. Classifier returns a string and LineCoding returns a string.

So StringConv = OutType + OutClass + OutLine retruns a string. I want to check if this string contains a question mark so "~?" and if so turn the Cell's font colour to Red and Bold the font.

I'm well aware of

( ).Font.Color = RGB(255, 0, 0)
( ).Font.Bold = TRUE

My problem is I do not know how to reference the cell that the function is located in. The function will not always be in column F and it will not always be in the column directly after variable input. This is my real problem, finding the question mark should be pretty easy with something like:

If InStr(strInput, "~?") > 0 Then
( ).Font.Color = RGB(255, 0, 0)
( ).Font.Bold = TRUE
End If

I'd also not want to have to have another variable selecting the cell that the function is in. If its any help, the first cell I select is always in Column A.

Anyways any help is much appriciated!