+ Reply to Thread
Results 1 to 6 of 6

Pass variable between subs within module

  1. #1
    Registered User
    Join Date
    08-05-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    61

    Pass variable between subs within module

    Having trouble passing the current state of Application.MoveAfterReturnDirection between 2 subs, in one module, that are executed on workbookopen and beforeworkbookclose.

    Code of this workbook
    Please Login or Register  to view this content.
    Code of Module 1
    Please Login or Register  to view this content.
    The MsgBox executes and provides a number -4161, which I hopes excel interprets as xIDown.

    I haven't changed any of the names yet, originally I just set it to move right on open, and move down on close. Worked fine, but many people will be using this workbook and I don't want to force down on them if they had something else set.
    Could use some help figuring out what I'm doing wrong.
    Last edited by oOarthurOo; 04-01-2010 at 04:54 PM.

  2. #2
    Registered User
    Join Date
    08-05-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Pass variable between subs within module

    Tried it somewhat differently, but still not working. Here is my second try:

    Content of Module 1
    Please Login or Register  to view this content.
    Content of This workbook
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-05-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Pass variable between subs within module

    Final try, just to show you guys that I am working on the probem. I just don't know enough about it I guess. Anyway, based on a similar question found I google I tried the following:

    All of this is in my workbook, no modules exist anymore.
    Please Login or Register  to view this content.

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

    Re: Pass variable between subs within module

    In ThisWorkbook:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    08-05-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Pass variable between subs within module

    Quote Originally Posted by shg View Post
    In ThisWorkbook:
    Please Login or Register  to view this content.
    Worked a treat. I can see several elements I knew nothing about ... declaring a variable as a move direction, and cancelling boolean, which I will need to read up on.

    Thanks very much!

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

    Re: Pass variable between subs within module

    ... declaring a variable as a move direction ...
    xlDirection is an enumeration (one of many in Excel), which is a list of values that a variable type can assume. xlLeft, xlRight, ... are members of that enumeration.

    ... and cancelling boolean ...
    You can read about that in Help for the BeforeClose event.

+ 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