Results 1 to 7 of 7
  1. #1
    3 Star Lounger Jimmy-W's Avatar
    Join Date
    Jan 2001
    Location
    Helena, Montana, USA
    Posts
    220
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Convert VBA function to macro

    I have a VBA module in my Personal.xlsb that begins as "Function name_of_function" on the top line. When I want to run it, I must enter =Personal.xlsb!function. Is there a way to get the module into a macro that I can run Macros list? There are actually two functions in the module. Thanks.
    JimmyW
    Helena, MT

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    You must convert it to a SUB and it must not have any parameters to run it from the Macro list.

    Steve

  3. #3
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,199
    Thanks
    48
    Thanked 987 Times in 917 Posts
    You should be able to add a button to run it.

    cheers, Paul

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    You can add a button to a function or a sub but if it has parameters it will give a runtime error.

    Steve

  5. #5
    3 Star Lounger Jimmy-W's Avatar
    Join Date
    Jan 2001
    Location
    Helena, Montana, USA
    Posts
    220
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Thanks, guys. I'm not sure about "parameters," but I'll guess that it does. The function converts one number base (16) to another (32), or vide versa. I'm basically looking for a quicker way to execute the code, instead of typing =Personal.xlsb!function, but that's really not that much of an inconvenience.
    Last edited by Jimmy-W; 2012-04-07 at 14:59.
    JimmyW
    Helena, MT

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    If you put a copy of the function into the workbook, you won't need the "personal.xlsb!". You need the workbook name since you must tell excel where it is located.

    Steve

  7. #7
    3 Star Lounger Jimmy-W's Avatar
    Join Date
    Jan 2001
    Location
    Helena, Montana, USA
    Posts
    220
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Thanks, everyone. I created an XLAM that contains the module, and it seems to do what I want.
    JimmyW
    Helena, MT

Posting Permissions

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