Consulting

Results 1 to 17 of 17

Thread: VBA module to Macro short cut and sharing to multiple users

  1. #1
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location

    VBA module to Macro short cut and sharing to multiple users

    Hi all

    I am not sure if it is the proper way, but I changed an excel VBA module to a Macro by just changing the module name to Sub macro() and also able to assign a short cut (Ctrl+A) for it. So if what i did is the proper way, then how do I share this to multiple computers / users where they can access the Macro whenever they open any Excel file (existing or new). My choice to convert it to Macro is for its short cut feature.
    Thank you for your time.

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    Would need code in each workbook to call procedure. Maybe https://www.mrexcel.com/board/thread...iables.465901/

    Possibly with a customized ribbon button.

    What does this procedure do?

    In Excel, a macro is still a VBA procedure.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    It would be best to NOT use the term 'Macro' for the name of your macro. You could abbreviate the term to 'Mcro' or maybe 'Maco' . Using the actual term 'macro' might confuse Excel and cause issues later.
    This would be the same thing for terms such as : COPY, PASTE, WRITE, INPUT BOX, etc. Those are all reserved terms Excel uses for objects or processes.

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You cannot change a module into a macro. A module is a container for code.

    Your best bet is probably to turn the workbook into an add-in and distribute that.
    Be as you wish to seem

  5. #5
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location
    Thanks Aflatoon

    One reason I want to convert the VBA module to a Macro is the short - cut so user does not have to deal with running the module. I can not also create a command button to run as I wanted these module to be available on any Excel file for all users. So as you said if i turn the workbook into add- ins, can I also assign a short cut to run the module from any computer / user.
    thanks again

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    A possibly simpler option would be to create an XLSM with the macro, assign a shortcut key to that macro, save it in XLSTART folder, then hide the workbook
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    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

  7. #7
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location
    Hi all thank you for your reply. At this point i am now more inclined to using an Excel Add - ins. The add - ins also allows me to create a quick access toolbar. Now Unfortunately when i convert it to an add ins and tired to use it on a new worksheet, in some of the result, the worksheet i used to create the add ins keeps coming, rather than the updated version which i want to see.

  8. #8
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Firstly, the QAT is for user customisations really - you should be using a custom ribbon. Second, I suspect that is your problem anyway as the QAT will include links with the file path, which may well be why you keep seeing the old version appear.
    Be as you wish to seem

  9. #9
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location
    Thank you for your time Aflatoon. But do you have any tip on how to create the Custom ribbon for an Excel Add ins.

    Thank you again

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    ---------------------------------------------------------------------------------------------------------------------

    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

  11. #11
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    I always recommend this as the place to start: https://www.rondebruin.nl/win/section2.htm

    I would recommend the add-in approach versus a hidden workbook, especially if you want a customised ribbon setup.
    Be as you wish to seem

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Quote Originally Posted by Aflatoon View Post
    I always recommend this as the place to start: https://www.rondebruin.nl/win/section2.htm

    I would recommend the add-in approach versus a hidden workbook, especially if you want a customised ribbon setup.

    1. Also a good place

    2. I was thinking that a hidden workbook would more easily allow a QAT icon and a shortcut key
    ---------------------------------------------------------------------------------------------------------------------

    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

  13. #13
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    I don't see how that would be any easier?

    Also, in my opinion, the QAT is for the user to customise, not for distributed workbooks. They should use the ribbon - and that won't work if the workbook is hidden, as best I recall. It's also a lot easier to distribute an add-in in my experience, especially if users want the ability to enable/disable it easily.

    Anyway, at least the OP now has a myriad of options.
    Be as you wish to seem

  14. #14
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location
    Thanks both. I will explore both suggestions

    Thanks again

  15. #15
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Quote Originally Posted by Aflatoon View Post
    I don't see how that would be any easier?

    Also, in my opinion, the QAT is for the user to customise, not for distributed workbooks. They should use the ribbon - and that won't work if the workbook is hidden, as best I recall. It's also a lot easier to distribute an add-in in my experience, especially if users want the ability to enable/disable it easily.

    Anyway, at least the OP now has a myriad of options.

    1. OP doesn't have to muddle their way through learning CustomUI and Fluent

    2. Yes, I (mostly) agree, but IMHO the QAT is not too difficult for a user since all the options, functions, etc. are right there

    3. Yes, if I had a workbook with a lot of functions, options, etc. (and I do ) I'd make it an addin. This seems like it's only one Sub in the WB

    4. Again IMHO, telling users how to install an add-in and telling them to copy the hidden workbook to XLSTART seems a wash.

    But...

    As you and OP said, there are options to investigate
    ---------------------------------------------------------------------------------------------------------------------

    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

  16. #16
    VBAX Regular
    Joined
    Jul 2023
    Posts
    13
    Location
    I think it is better i share my Excel file and what it does.

    The worksheet "Pdata" is holding the data
    All output will be stored on the PowerDetail worksheet.
    At first it SUMS the row in Pdata and puts it in PowerDetail Column B (you see it in green)
    Now using the green data the GPI table is calculated as High, moderate and low.
    The central tendency table is calculated from the Pdata worksheet again and it calculate each columns Mean, Median and Mode (see the column title here it matches with the source worksheet "pdata")
    The Occurrences of Responses table is also calculated from Pdata worksheet and counts and also get the percentage of the counts of 4,3,2,1 and 0's (Also note the Row names in here exactly matches with the source worksheet "pdata")
    The issue:
    If you run the code now all works fine you can also go to the "pData" worksheet and change the column name both the Central Tendency and occurrences table will also update the names accordingly, but if you create this as an Excel Add - ins. It runs fine, but when you change the column names on "pData" worksheet it does not update it on pwerDetail worksheet. Hope this help to see the issue i have.
    Attached Files Attached Files

  17. #17
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    I put the macro code into the addin (XLAM), but the data is now in a stand-alone XLSX workbook

    I made the add-in explicitly refer to Activework in multiple places, and changed Thisworkbook to Activeworkbook in one

    I added the macro to the QAT but it could easily be added to the ribbon

    I think that the way it was, it was updating the worksheets in the addin, but I'm GUESSING that you wanted the distributed macro to update the users' visible workbooks ???
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    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

Posting Permissions

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