Referencing a cell's format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a sheet that is referencing another
Is there a way of referencing a cell's value AND it's format (bold, borders etc..)
 
Hi
formulas can only return values. So no way to link formats with
formulas between two cells
 
I have a sheet that is referencing another.
Is there a way of referencing a cell's value AND it's format (bold, borders etc..)

You can do that with a VBA User Defined Function.

For example, here is one UDF that returns TRUE if the referenced cell(s) are
formatted "italic" and FALSE if not:

=====================
Function IsItalic(rg As Range) As Variant
Application.Volatile
Dim c As Range, i As Integer, j As Integer
Dim N()

i = 0
For Each c In rg
i = i + 1
Next c
ReDim N(i - 1)

j = 0
For Each c In rg
N(j) = c.Font.Italic
j = j + 1
Next c

IsItalic = N
End Function
====================

One caveat: Changing the format of a cell does NOT trigger recalculation. So
when you change a format, you will not see the result of this UDF change until
something causes the sheet to recalculate.


--ron
 
Back
Top