PC Review


Reply
Thread Tools Rate Thread

How to create a function in a code sheet

 
 
Mathieu936
Guest
Posts: n/a
 
      31st May 2010
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
 
Reply With Quote
 
 
 
 
Harald Staff
Guest
Posts: n/a
 
      31st May 2010
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" <(E-Mail Removed)> wrote in message
news:be516a8c-8cf1-4b67-a7cc-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Wouter HM
Guest
Posts: n/a
 
      31st May 2010
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
 
Reply With Quote
 
Mathieu936
Guest
Posts: n/a
 
      1st Jun 2010
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.
 
Reply With Quote
 
Mathieu936
Guest
Posts: n/a
 
      11th Jun 2010
On 1 juin, 13:09, Mathieu936 <mathieu...@gmail.com> 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?
 
Reply With Quote
 
James Ravenswood
Guest
Posts: n/a
 
      12th Jun 2010
On Jun 11, 12:39*pm, Mathieu936 <mathieu...@gmail.com> wrote:
> On 1 juin, 13:09, Mathieu936 <mathieu...@gmail.com> 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.
 
Reply With Quote
 
Mathieu936
Guest
Posts: n/a
 
      14th Jun 2010
On 12 juin, 07:14, James Ravenswood <james.ravensw...@gmail.com>
wrote:
> On Jun 11, 12:39*pm, Mathieu936 <mathieu...@gmail.com> wrote:
>
> > On 1 juin, 13:09, Mathieu936 <mathieu...@gmail.com> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use VBA to create new sheet with event handlers in sheet's code VBAer Microsoft Excel Programming 2 24th Nov 2009 07:22 AM
create new sheet with zip code as name Rich Microsoft Excel Programming 5 28th Jul 2009 11:19 AM
Code to create atbs in excel sheet deepa prabhakar Microsoft Excel Misc 1 26th May 2006 09:28 PM
Code to create tabs in single excel sheet deepa prabhakar Microsoft Excel Misc 1 26th May 2006 10:15 AM
Code to create and name a sheet =?Utf-8?B?ZG9ncGlnZmlzaA==?= Microsoft Excel Programming 8 5th Jan 2006 03:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 PM.