+ Reply to Thread
Results 1 to 4 of 4

Using a value from one subroutine in another.

  1. #1
    Registered User
    Join Date
    07-08-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2003
    Posts
    17

    Using a value from one subroutine in another.

    Hello, I am designing my first UserForm structure in VBA (having had programming experience in school) for my internship. One thing I was wondering was how to push the value of a variable from one subroutine (say a text box in this case) to another subroutine.

    Please Login or Register  to view this content.
    Then once I get that BlockNumber moved to the second subroutine on the form (this one is a okay button) i was wondering if there was anyway to use that value (BlockNumber) in a directory to open a file? So replace that "9043" in the directory with a form of BlockNumber that is specified by the user.


    Please Login or Register  to view this content.
    if this is too confusing I can try to explain clearer, thanks a lot!
    Last edited by rmar2011; 07-26-2011 at 02:18 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Using a value from one subroutine in another.

    Since you have the textbox available to both routines, the first one serves little purpose really (you would have to declare Blocknumber outside that routine for it to retain its value after the routine finished). Try just:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    07-08-2011
    Location
    Cleveland, OH
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Using a value from one subroutine in another.

    That worked great! Thanks a lot, I figured I was being repetitive with those subroutines but since this has been my first two days working with VBA I wasn't sure.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Using a value from one subroutine in another.

    Glad to help. (boilerplate request follows...)

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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