+ Reply to Thread
Results 1 to 6 of 6

What is easier? writing many sub routines or just one long one.

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    What is easier? writing many sub routines or just one long one.

    i am currently writing a vba code that uses mathematical formulas to iterate and display results graphically. I am currently have an issue of reusing ending variables in next subroutine from previous subroutine. The code is mostly done except for a few debugging issues. Basically, how do I get variable from previous subroutine visible for next subroutine. Any help or direction would be greatly appreciated.
    Last edited by damayn83; 01-18-2013 at 05:49 PM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: What is easier? writing many sub routines or just one long one.

    Declare varibles at module level, so the varaibles would be available throught the module.

  3. #3
    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: What is easier? writing many sub routines or just one long one.

    I would pass them from one to the next, just as you pass arguments to Excel's native functions in formulas. Small routines that perform relatively atomic functions are easier to maintain and more reusable.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: What is easier? writing many sub routines or just one long one.

    Pass values from one procedure or function via its argument list.
    Please Login or Register  to view this content.
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    Re: What is easier? writing many sub routines or just one long one.

    to declare variables at module level, is that just dimensioning them before any line of code?

  6. #6
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    Re: What is easier? writing many sub routines or just one long one.

    Thank you AB33. That solved it. Now on to rest of code.

+ 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