Results 1 to 5 of 5
  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

    Store frequently used functions

    I have a few functions that I use periodically, though not often enough to have committed their syntaxes to memory. Is there a way that I can store them in my Personal workbook so that I can recall them more easily? For example, I'd like to save a function like =MID(A1,Find("text",A1)+1,25), and then edit the paramters as needed. Thanks.
    JimmyW
    Helena, MT

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Jimmy,

    You can create a User Defined Function in your Personal.xls file that you the call with the necessary arguments, e.g.

    Public Function MyMidFind( zTarget as String, zFindWhat as String, iCharCnt as Integer)

    MyMidFind = Mid(Range(zTarget),Instr(zFindWhat,Range(zTarget)) +1,iCharCnt)

    End Function

    You would call it in your worksheet with the formula =MyMidFind(A1,"Text",25)

    Disclaimer: This is strictly AIR CODE and is untested but is designed to convey the concepts.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    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
    [whisper]You would call it like:
    =Personal.xls!MyMidFind(A1,"Text",25)

    You have to explicitly list the workbook name for functions external to the workbook

    Steve

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts
    Maybe I missed something here.

    When I type =MID( in a cell, a tool tip appears in the formula bar that gives the syntax of the MID function showing what the parameters are. In your example, Jimmy, when you type the embedded FIND with its following parens, Excel shows you the syntax for FIND. When you type the close paren for the FIND, Excel resumes showing the MID syntax.

    Since each parameter of a function can be an argument of cells, Excel can't possible show all possibilities. So if a value is called for, you can a constant like 43, a cell reference like A1, or even a formula like A1+B1 or FIND(x,y)+1.

    [whisper] So if you don't recall the syntax for the MID function, I'm not sure how calling a UDF helps when the UDF needs the same parameters.

    What did I miss?

    Fred

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Quote Originally Posted by sdckapr View Post
    [whisper]You would call it like:
    =Personal.xls!MyMidFind(A1,"Text",25)

    You have to explicitly list the workbook name for functions external to the workbook

    Steve
    Steve,

    Thanks for the reminder no need to [whisper] I can take it.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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