+ Reply to Thread
Results 1 to 8 of 8

Running a SUB inside of another SUB

  1. #1
    Registered User
    Join Date
    05-15-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Running a SUB inside of another SUB

    DISCUSSION:

    I have some general code that needs to be kept tidy so I have been experimenting with calling other Modules to keep that general code short and sweet.

    PROBLEM:

    How to put the SUB's inside of another SUB on a separate Module?

    Here is the desired pertinent code on the general code sheet:

    Please Login or Register  to view this content.
    Here is what I currently have in a separate Module:

    Please Login or Register  to view this content.

    ANTICIPATED SOLUTION:

    I'm thinking of some brackets of some sort around the second set of supplied code but am not sure if that will work or is possible in VBA.

    NOTES:

    This is an updated workbook from a previous thread found here:

    http://www.excelforum.com/excel-prog...ml#post2106854
    Last edited by gmcconnell; 06-09-2009 at 11:52 AM. Reason: updated code for clarity and fixed link
    Thank you for your time and help,

    Glenver McConnell

  2. #2
    Registered User
    Join Date
    05-15-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Running a SUB inside of another SUB

    The more I think about the less I think that it's possible but I know that you guys have come up with some pretty cool stuff in the past!

  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Running a SUB inside of another SUB

    Your link is broken, you can't place a sub within another sub, (and I can't see why you would want to), but you can call another sub from within a sub.

    Your question though doesn't give enough information about what you are trying to achieve for me to help you.

    Your first code block contains a single line of code:
    Please Login or Register  to view this content.
    But I can't see what / where this refers to? It's certainly not present in your second code box...
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  4. #4
    Registered User
    Join Date
    05-15-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Running a SUB inside of another SUB

    I fixed the problems you mentioned, The second box now shows completely what I currently have in a separate Module. Yes, I know it doesn't work but I think you can imagine what I want from the new addition.

    The only reason I would want to do something like this would be to reduce the clutter on my general programming page. I'm thinking I may just have to live with it.

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Running a SUB inside of another SUB

    The second set of code runs automatically when any of those comboboxes change so why do you need to call them from another procedure?

  6. #6
    Registered User
    Join Date
    05-15-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Running a SUB inside of another SUB

    Quote Originally Posted by StephenR View Post
    The second set of code runs automatically when any of those comboboxes change so why do you need to call them from another procedure?
    I don't I guess, I was just looking for a way to get one or two lines on the general sheet instead of the longer code I provided in the second code blurb. I'm just going to live with it, I have minimized enough other stuff that it's now easier to navigate.

    Thank you for your help!

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Running a SUB inside of another SUB

    As Stephen, I can't see why you are wanting to run these functions manually, but this is how you would have to do it:

    In one module:
    Please Login or Register  to view this content.
    In the other module:
    Please Login or Register  to view this content.
    Last edited by Phil_V; 06-09-2009 at 11:53 AM. Reason: Missed the closing code tag

  8. #8
    Registered User
    Join Date
    05-15-2009
    Location
    New York, USA
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Running a SUB inside of another SUB

    That looks good, once again, it's just to make the code easier for me to navigate and read, it's getting pretty lengthy.

    Thanks for the help, if I ever get all of the other bugs figured out I'll give that one a try for sure.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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