ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to create a function in a code sheet (https://www.excelbanter.com/excel-programming/442980-how-create-function-code-sheet.html)

Mathieu936

How to create a function in a code sheet
 
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

Harald Staff[_2_]

How to create a function in a code sheet
 
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

"Mathieu936" wrote in message
...
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



Wouter HM

How to create a function in a code sheet
 
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

Mathieu936

How to create a function in a code sheet
 
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.

Mathieu936

How to create a function in a code sheet
 
On 1 juin, 13:09, Mathieu936 wrote:
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?

James Ravenswood

How to create a function in a code sheet
 
On Jun 11, 12:39*pm, Mathieu936 wrote:
On 1 juin, 13:09, Mathieu936 wrote:

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?


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.

Mathieu936

How to create a function in a code sheet
 
On 12 juin, 07:14, James Ravenswood
wrote:
On Jun 11, 12:39*pm, Mathieu936 wrote:

On 1 juin, 13:09, Mathieu936 wrote:


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?


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!


All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com