Creating Functions

  • Thread starter Thread starter -=Merovingian=-
  • Start date Start date
M

-=Merovingian=-

Hi all

I suspect that this is a really simple easy question but it is annoying
with the lack of information available......

I have created a function called

weekno(ipdata as date) as integer

and have put it in -thisworkbook- on the vba editor.....

Firstly is this the correct place to put functions or do I need a
module?
Secondly is I go to any of the sheets and in a cell put =weekno(K4) for
example, I get #Name? - how do I make it reference -thisworkbook- to
tell it that the function is located there?

Any help is appreciated.
 
The simple solution would be to put the function in a module.

--
Cheers
Nigel



"-=Merovingian=-"
 
"-=Merovingian=-"

[...]
Firstly is this the correct place to put functions or do I need a
module?
Secondly is I go to any of the sheets and in a cell put =weekno(K4) for
example, I get #Name? - how do I make it reference -thisworkbook- to
tell it that the function is located there?

Put in a module all you need do be "visible" from anywhere.

Ciao
Bruno
 
Hello,

Thisworkbook is a place to put a code if you want to bind the code to an
event. (ex. Workbook_Open located in Thisworkbook is triggered when the
workbook opens)

Functions that you want available all the time as long as this workbook is
open, you put in a module.

Remember yet that if you have activated the following command

AddIn from the menu Tools-AddIns...-Analysis ToolPack

then you already have enabled a function =WEEKNUM(date) that returns a
weeknumber of a givendate.

Regards, Mika

"-=Merovingian=-"
 

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

Back
Top