Consulting

Results 1 to 3 of 3

Thread: vba Personal workbook - I dont get it

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location

    vba Personal workbook - I dont get it

    I am a bit confused about the personal workbook and what it's supposed to do? So I saved a few macros in the personal workbook, but if I want them to work in other workbooks I have to copy those macros into that workbook? What was the point of saving them in the personal workbook?

    I have a workbook into which I have copied macros from my personal workbook. However, this other workbook will be used
    every month, and saved with a new name (eg. Jan Sales - Feb Sales). My problem is that when the file is 'rolled forward'
    any macro that is executed also open the Jan file. I was under the impression that having those macros in the personal
    would prevent this?
    Most of the resources that I have seen online describes how to create the personal workbook as opposed to how to use it.
    Any clarification would be appreciated.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Just a couple of points


    You can use Personal subs and functions in another workbook's macros or the functions in in another workbook's worksheet, …

    BUT the Personal subs and functions have to written general purpose enough

    a. Proper use of ThisWorkbook and ActiveWorkbook
    b. No hardcoding that will prevent use by another workbook
    c. Probably a lot more

    I keep my Personal.xlsm in my XLSTART folder (I prefer xlsm instead of xlsb)


    1. You can directly call a Personal macro sub from Alt-F8 if it doesn't require parameters

    Capture.JPG


    2. You can make it a Reference so that you do not need the "Personal.xlm!". A sub like this will take paramerters

    Capture2.JPG




    Option Explicit
    
    Sub DefinedAsReference()
        FilterOnSelection
    End Sub
    
    
    Sub NotDefinedAsReference()
        Application.Run "personal.xlsm!FilterOnSelection"
    End Sub

    3. You can call a Personal function on the worksheet

    Capture3.JPG


    Edit -- 4. A lot of people will keep their 'toolkit' macros in Personal.xlsm so that they can call / use them on any open visible workbook


    I'm sure others will have additional ideas
    Last edited by Paul_Hossler; 01-11-2019 at 02:41 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location
    This is really helpful. Thank you for the excellent explanation!

Posting Permissions

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