Font attributes as arguments

Copper Contributor

How can I use Font attributes as an argument in formulas?  For example, check the font in a cell for "strikethrough", or "bold", then return some 

1 Reply

@Scott Rothermel 

The easiest way to do this is to create one or more custom VBA functions. For example

Function IsBold(rng As Range) As Boolean
    Application.Volatile
    On Error Resume Next
    IsBold = rng.Font.Bold
End Function

Example of usage: =IsBold(A1) will return TRUE if the entire cell A1 is bold, FALSE if it is partly or entirely not bold.

Warning: the result of the formula will not be updated automatically when you make A1 bold or not bold, but it will be updated when Excel performs any calculation.

 

An alternative is to use Excel 4 Macro functions, but that is rather awkward.