Jim
Jim

Reputation: 609

Excel return Cell Style in a fromula

In Excel how do I return the Style name applied to a cell as a formula?

When i use the =CELL("Color",AA11) (see below) it doesn't return a colour value, it still thinks it is unformatted, none of the other =Cell() functions seem to return style info either.

Example

These are the styles as given by excel, I've marked a bunch of fields as good, bad or neutral. Ideally I'd like to be able to return 'Good' or 'Bad' etc into a cell.

Styles

Thanks

Upvotes: 1

Views: 2145

Answers (1)

JvdV
JvdV

Reputation: 75870

Here is a very easy UDF:

Function GetStyle(rng As Range)
    GetStyle = rng.Style
End Function

Call in your cell B2 like =GetStyle(B2)

Edit

It's good to realize a UDF wont recalculate when you are changing the format of a cell!

Upvotes: 2

Related Questions