Using VBA function as worksheet function?

  • Thread starter Thread starter Nekdo Od Nekje
  • Start date Start date
N

Nekdo Od Nekje

Hello?

Anybody knows if is it posible (and how) to define a VBA
function to use it as a worksheet function. I tried and I
defined a such test one but I always got the #NAME? error
on worksheet?

NON
 
Hi
in a module of your workbook try

Public Function foo(rng as range) as integer
' insert your code and adapt the function parameters....
foo = 1
End Function

Frank
 
Hi Nekdo!

Here's a simple one:

Function COLOR(MyCell As Range)
COLOR = MyCell.Interior.ColorIndex
End Function

This function will be usable provided it is in an open workbook, the
Personal.xls (which is an open workbook), or in an Addin that has been
installed and selected as an Addin.


--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Thanks, it works!

I tried to insert my code in Microsoft Excel Object in
Sheet1 and in ThisWorkbook. It was obviosly the wrong
place!?

NON
 
Back
Top