+ Reply to Thread
Results 1 to 3 of 3

Global (Module) Variable Problem

  1. #1
    Allen Geddes
    Guest

    Global (Module) Variable Problem

    In Module "This Workbook" I've declared a global variable using the following
    statement:

    Public mSelection As Integer



    In a UserForm, I've assigned a value to the variable using the following
    statement:

    Private Sub btnSprintSubmit_Click()

    mSelection = lbSprint.ListIndex

    End Sub



    Now, in ANOTHER UserForm, I have a Case Statement that fills in all of the
    labels on the UserForm, based on the value of mSelection. But, when I step
    through the code in that UserForm, the value of mSelection is "Empty". How
    come the value of mSelections isn't passing from one UserForm to the next?
    Am I declaring the global variable incorrectly? Any help/advice/tips are
    greatly appreciated! Thank you

    -Allen

  2. #2
    Chip Pearson
    Guest

    Re: Global (Module) Variable Problem

    Take the variable mSelection out of the ThisWorkbook module and
    put it in a standard code module.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Allen Geddes" <[email protected]> wrote in
    message
    news:[email protected]...
    > In Module "This Workbook" I've declared a global variable using
    > the following
    > statement:
    >
    > Public mSelection As Integer
    >
    >
    >
    > In a UserForm, I've assigned a value to the variable using the
    > following
    > statement:
    >
    > Private Sub btnSprintSubmit_Click()
    >
    > mSelection = lbSprint.ListIndex
    >
    > End Sub
    >
    >
    >
    > Now, in ANOTHER UserForm, I have a Case Statement that fills in
    > all of the
    > labels on the UserForm, based on the value of mSelection. But,
    > when I step
    > through the code in that UserForm, the value of mSelection is
    > "Empty". How
    > come the value of mSelections isn't passing from one UserForm
    > to the next?
    > Am I declaring the global variable incorrectly? Any
    > help/advice/tips are
    > greatly appreciated! Thank you
    >
    > -Allen




  3. #3
    Allen Geddes
    Guest

    Re: Global (Module) Variable Problem

    Perfect. Thanks a million Chip!!!!

    -Allen



    "Chip Pearson" wrote:

    > Take the variable mSelection out of the ThisWorkbook module and
    > put it in a standard code module.
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "Allen Geddes" <[email protected]> wrote in
    > message
    > news:[email protected]...
    > > In Module "This Workbook" I've declared a global variable using
    > > the following
    > > statement:
    > >
    > > Public mSelection As Integer
    > >
    > >
    > >
    > > In a UserForm, I've assigned a value to the variable using the
    > > following
    > > statement:
    > >
    > > Private Sub btnSprintSubmit_Click()
    > >
    > > mSelection = lbSprint.ListIndex
    > >
    > > End Sub
    > >
    > >
    > >
    > > Now, in ANOTHER UserForm, I have a Case Statement that fills in
    > > all of the
    > > labels on the UserForm, based on the value of mSelection. But,
    > > when I step
    > > through the code in that UserForm, the value of mSelection is
    > > "Empty". How
    > > come the value of mSelections isn't passing from one UserForm
    > > to the next?
    > > Am I declaring the global variable incorrectly? Any
    > > help/advice/tips are
    > > greatly appreciated! Thank you
    > >
    > > -Allen

    >
    >
    >


+ 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