I am trying to create a formula that can red the text color from another cell....so =if (e4cell red),then "e12-100") Can something like this be done?
It can be either the cell text color or I can fill the necessary with color
I am trying to create a formula that can red the text color from another cell....so =if (e4cell red),then "e12-100") Can something like this be done?
It can be either the cell text color or I can fill the necessary with color
There isn't a standard formula to read a cell's text colour, but you can write a user-defined function to do so:
One issue with this is that changing a cell's text colour does not trigger a recalculation, so even if the function is volatile you'll still have to press F9 to do a sheet recalculation every time a cell's colour changes, or the result from the formula won't update.![]()
Function TextColour(rngTarget As Range) As String Application.Volatile Dim vColMatch As Variant Dim vColList As Variant Dim vColName As Variant vColList = Array(vbRed, vbGreen, vbYellow, vbBlue, vbBlack, vbWhite) vColName = Array("Red", "Green", "Yellow", "Blue", "Black", "White") vColMatch = Application.Match(rngTarget.Font.Color, vColList, 0) If IsError(vColMatch) Then TextColour = "Unknown" Else TextColour = vColName(vColMatch - (1 - LBound(vColName))) End If End Function
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks