UDF is not working until pressing enter key in Excel

Viewed 76

If someone pasted text in a data validation dropdown and it doesn't match with the Data validation list, I'm highlighting the cell by using a red font color range..Font.Color = vbRed

I'm using the below UDF as an Excel formula to find out the font color of the cell, but this UDF is not calling until I select the cell, go to formula bar and hit enter.

Function GetColorText(pRange As Range) As Integer

Application.Volatile

    If IsEmpty(pRange) Then Exit Function

    Dim xOut As Integer

    xOut = pRange.Font.ColorIndex

    GetColorText = xOut

End Function
0 Answers
Related