ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   function formatting a cell (https://www.excelbanter.com/excel-discussion-misc-queries/166465-function-formatting-cell.html)

papero

function formatting a cell
 
Suppose I have a value in A1 and the formula
=FormatCell(A1), calling the following macro, in B1

Function FormatCell(a As Range)
a.Cells(1, 1).Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
End Function

Why I hav'nt A1 formatted?
I have breakpointed the macro and it triggers when I change the A1
value.

Bye, Emiliano

Gary''s Student

function formatting a cell
 
A UDF cannot directly change the format of a cell.
--
Gary''s Student - gsnu2007a


"papero" wrote:

Suppose I have a value in A1 and the formula
=FormatCell(A1), calling the following macro, in B1

Function FormatCell(a As Range)
a.Cells(1, 1).Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
End Function

Why I hav'nt A1 formatted?
I have breakpointed the macro and it triggers when I change the A1
value.

Bye, Emiliano


eggpap

function formatting a cell
 
Thanks, any advice to get it?
I used the UDF since I've to manage complex conditions.

Emiliano

"Gary''s Student" ha scritto nel
messaggio ...
A UDF cannot directly change the format of a cell.
--
Gary''s Student - gsnu2007a


"papero" wrote:

Suppose I have a value in A1 and the formula
=FormatCell(A1), calling the following macro, in B1

Function FormatCell(a As Range)
a.Cells(1, 1).Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
End Function

Why I hav'nt A1 formatted?
I have breakpointed the macro and it triggers when I change the A1
value.

Bye, Emiliano





Gary''s Student

function formatting a cell
 
Two approaches:

1. Use the UDF, (or something like it) to set a Conditional Format.
2. Put the UDF or related UDF in a worksheet cell and use a Calculate Event
Macro to paint formats based upon the value returned.
--
Gary''s Student - gsnu2007a


"eggpap" wrote:

Thanks, any advice to get it?
I used the UDF since I've to manage complex conditions.

Emiliano

"Gary''s Student" ha scritto nel
messaggio ...
A UDF cannot directly change the format of a cell.
--
Gary''s Student - gsnu2007a


"papero" wrote:

Suppose I have a value in A1 and the formula
=FormatCell(A1), calling the following macro, in B1

Function FormatCell(a As Range)
a.Cells(1, 1).Select
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
End Function

Why I hav'nt A1 formatted?
I have breakpointed the macro and it triggers when I change the A1
value.

Bye, Emiliano







All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com