How to create a function in a code sheet

M

Mathieu936

Hi!

I need to create a function that I will use in a worksheet. However,
I need to create it in a worksheet code (not in a separate module, but
in the "Microsoft Excel Objects").

I know it works for a macro, but not for a function. I tried to call
my function with "private function", "public function", but it doesn't
work.

Thanks for your help guys!

Mathieu
 
H

Harald Staff

Hi Mathieu

Why on earth do you "need to create it in a worksheet code, not in a
separate module" ? Insert a regular module and write your function, end
users don't care where or how functions are written.

HTH. Best wishes Harald
 
W

Wouter HM

Hi Mathieu

If you put the line below in the separate module your users will not
find the function in the list of t category User Defined

Option Private Module.


HTH,

Wouter
 
M

Mathieu936

I want to include the functions in the worksheet code because I have
to copy the worksheet, and I don't want to copy a module with it.
That's the only reason.
 
M

Mathieu936

I want to include the functions in the worksheet code because I have
to copy the worksheet, and I don't want to copy a module with it.
That's the only reason.

anyone has an idea?
 
J

James Ravenswood

anyone has an idea?

An alternate approach to worksheet event macro in the sheet. The
macro would:

1. test for the existence of a module called mathieu
2. if the module already exists in the work book, just exit
3. create the module
3. populate the newly created module with any functions or sub you
need.
 
M

Mathieu936

An alternate approach to worksheet event macro in the sheet.  The
macro would:

1. test for the existence of a module called mathieu
2. if the module already exists in the work book, just exit
3. create the module
3. populate the newly created module with any functions or sub you
need.

Thanks James for the idea. Thus I assume there is no way to write a
function in the sheet's code. Too bad!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top