+ Reply to Thread
Results 1 to 5 of 5

Creating Functions

  1. #1
    Registered User
    Join Date
    10-30-2005
    Posts
    1

    Creating Functions

    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.
    Regards
    Merovingian

  2. #2
    Nigel
    Guest

    Re: Creating Functions

    The simple solution would be to put the function in a module.

    --
    Cheers
    Nigel



    "-=Merovingian=-"
    <Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com> wrote in message
    news:Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com...
    >
    > 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.
    >
    >
    > --
    > -=Merovingian=-
    >
    >
    > ------------------------------------------------------------------------
    > -=Merovingian=-'s Profile:

    http://www.excelforum.com/member.php...o&userid=28443
    > View this thread: http://www.excelforum.com/showthread...hreadid=480421
    >




  3. #3
    Bruno Campanini
    Guest

    Re: Creating Functions

    "-=Merovingian=-"
    <Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com> wrote in message
    news:Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com...

    [...]
    > 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



  4. #4
    Don Guillett
    Guest

    Re: Creating Functions

    Module

    --
    Don Guillett
    SalesAid Software
    donaldb@281.com
    "-=Merovingian=-"
    <Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com> wrote in message
    news:Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com...
    >
    > 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.
    >
    >
    > --
    > -=Merovingian=-
    >
    >
    > ------------------------------------------------------------------------
    > -=Merovingian=-'s Profile:

    http://www.excelforum.com/member.php...o&userid=28443
    > View this thread: http://www.excelforum.com/showthread...hreadid=480421
    >




  5. #5
    Mika Oukka
    Guest

    Re: Creating Functions

    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=-"
    <Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com> wrote in message
    news:Merovingian-.1xpp6b_1130670305.2594@excelforum-nospam.com...
    >
    > 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.
    >
    >
    > --
    > -=Merovingian=-
    >
    >
    > ------------------------------------------------------------------------
    > -=Merovingian=-'s Profile:

    http://www.excelforum.com/member.php...o&userid=28443
    > View this thread: http://www.excelforum.com/showthread...hreadid=480421
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1