View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default use vba function in formula

Your function can be called as any other worksheet function, exactly as you
show. AN example function is

In your function you should only look to manipulate the input data, or some
fixed worksheet data, and return a result. You should not try to amend any
worksheet/cell attributes such as the cell colour, font, it will not work.

So your function might look like as an example

Public Function AnyReds(rng As Range) As Boolean
Dim cell As Range

For Each cell In rng
If cell.Interior.ColorIndex = 3 Then
AnyReds = True
Exit Function
End If
Next
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"news.wanadoo.fr" wrote in message
...
Hi !

Is ther any way to use some vba function i wrote in my cells formulas ??

for example : =myfunction(A1:A10)

with

function myfunction (myRange as range)
....
end Function

Thank you all for your answers

Sylvain Caillet