Change Cell properties by Function

G

Gilles P (FR)

Hello,

I like to change the colorIndex of a cell by a function is it possible ?
The code following doesn't works:

Function Fncolor(Value)
Worksheets("Sheet").Cells(RowNbr, ColumnNbr).Font.ColorIndex = 3
Fncouleur = "nnnnnn"
End Function

With a cell containing '=Fncolor(5)' to call the function

The goal is to avoid Format / condition limitation to 3 conditions....
Thanks for your Help

Gilles P(FR)
 
G

Gary''s Student

The colorindex can not be changed by a function alone. You would need an
event macro to operate in conjunction with the function.
 
G

Gilles P (FR)

So, to skip it i use these events to call the procedure

Sub Worksheet_Change(ByVal Target As Range)
macro Target 'Call a procedure to change
colorindex
End Sub
or
Sub Worksheet_SelectionChange (ByVal Target As Range)
macro Target 'Call a procedure to change
colorindex
End Sub


Is there no any other way ?
because the code will run on each change in worksheet.

Nota: To call an other procedure from function doesn't works too !!

Gilles P (FR)


"Gary''s Student" a écrit :
 
Top