+ Reply to Thread
Results 1 to 10 of 10

Combine subs to run and appear as one in macro list

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Combine subs to run and appear as one in macro list

    Hello all,

    Fairly simple question here...

    I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list?


    I tried making the 8 subs "private subs", and it did hide them, but then my call sub macro didn't work.

    Any thoughts?

    thanks
    Last edited by duugg; 07-23-2009 at 11:21 AM. Reason: searchability

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    Add

    Option Private Module

    to the top of the module with these subs, and make them all Public.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    If you put the 8 subs in the same module as the calling routine, Private Sub should work.

    Or you could introduce an optional argument to the subs.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    Bob and mike (Bob first, mike below)


    Okay here's my "Combine_Reports" sub as is


    Please Login or Register  to view this content.

    Then, I added

    Option Private Module

    and it looks like this


    Please Login or Register  to view this content.
    But once I do that, I go into Excel, hit the macro button, and the "Combine_Report" sub is no longer visible.

    Note that my module names are named like this

    Module_Report_Step_01
    Module_Report_Step_02

    etc..

    mike,

    I'm losing you on this part

    Please Login or Register  to view this content.
    Sorry to be such a newbie!

    thanks,

    duugg

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    All Option statements go at the top of the module, before any procedures.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    I said ...

    Add

    Option Private Module

    to the top of the module with these subs

    In other words, before any subs.

  7. #7
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    Okay,

    I was doing two things wrong.

    I was adding

    Please Login or Register  to view this content.
    to the "Combine Sub", but it was below the "Combine Sub"

    Then, I was adding it above the "Combine Sub"

    Then, I thought I was supposed to add the "ADD" to it. So I tried this

    Please Login or Register  to view this content.

    Then I took Add/Option Private Module away from the combine sub and added it instead to each sub I was calling, like this...

    Please Login or Register  to view this content.
    and that didn't work.


    What finally worked was this...

    Please Login or Register  to view this content.
    above each CALLED sub, without the ADD part.


    So, in short the answer for newbies like me would be this.

    Please Login or Register  to view this content.


    Nothing is actually done at all to the Sub "Combine_Reports"
    i.e. the one that calls all the reports

    I'm glad to finally get this one resolved, thanks to all

  8. #8
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    Sometimes we says things that are clear to us but we forget how others may not have the intrinsic understanding that we have and so we are not necessarily as clar as we might be.

    Glad you got it sorted.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    I'm glad the Option Private Module worked.

    To answer your question about the optional argument, in your situation, replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    and so forth with the other Report_Steps

  10. #10
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: I have a Sub that calls 8 other subs, can I hide the 8 subs on a users macro list

    Hey guys thanks for that and all your help again.

    hey mike, when you put "Optional Dummy as Boolean" I thought I was supposed to replace it with something else, duh to me for that

    I didn't think that words like "dummy' are actually vba code. Who wooda thunk? lol

    anyways, thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1