Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Sault Ste. Marie, Michigan, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA UDF question (xl2k sr1)

    I have a UDF in my personal.xls. I wanted to call it from a module in another workbook, but couldn't figure out a syntax to make it work. How is this done?

    Thanks,
    Ken

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBA UDF question (xl2k sr1)

    Could you make it an add-in(XLA)...It would make life simpler <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Jerry

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA UDF question (xl2k sr1)

    Yet another option: let's say that you have a function MyFunc in a module in Personal.xls that takes one argument. You can call it from a module in another workbook as follows:

    Dim a As Single
    a = Application.Run("Personal.xls!MyFunc", 10)

    Note that the first (and in this example only) argument to MyFunc is passed as the second argument of Application.Run. You can *not* use something like Application.Run("Personal.xls!MyFunc(10)") - it'll return an error.

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: VBA UDF question (xl2k sr1)

    You can set a reference to your Personal.xls file in the VBProject for the workbook you wish to use the function in.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Sault Ste. Marie, Michigan, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA UDF question (xl2k sr1)

    Thanks Jezza, Rory, and Hans. Got lots of options now.

    Ken

Posting Permissions

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