Can I use a User-Defined Funcion in a Conditional Format formula?

  • Thread starter Thread starter Sally
  • Start date Start date
yes you can. What is your function and how are you trying to call
it.

This works for me:

Public Function foo(bar As Range)
foo = 2 * bar.Value
End Function


CF1: Formula is =foo(A1) <=10 ==> patterns/red

turns the background cell color red if the cell value <=5
 
Barmaley said:
it does work

ok, I jumped the gun, but there seems to be something weird here.

I have one user defined function, all it does is return the value sent
Function rowTestInteger(r As Integer) As Integer
rowTestInteger = r
End Function

I have 6 cells a1::b3
all with the formula =rowTestInteger(ROW())

results
1 1
2 2
3 3

So far fine

In column a, the conditional format is the same for all three
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2

in Columns b, I change it a bit to
=rowTestInteger(b1)=2
=rowTestInteger(b2)=2
=rowTestInteger(b3)=2

I set the formats to background of red

a2 and b2 BOTH should be red, but only b2 is.
a2=2=ROW(), so it should be red too, but for some reason it is not!!!

-Sal
 
Back
Top