Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: help me please with variables

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    42
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    is it possible to carry the value of a variable defined in one user form into another user form?
    I can do it across modules using the 'public' declaration

    public myvariable as string

    the variable retains its value in a different module no problem.

    Do the same in a form (setting the variable by taking the value of a text box) and its fine until I switch to the next user form where the variable is empty! This is really bugging me!

    Anyone able to help, simple code available if needed.

    Andy

  2. #2
    Guest

    Default

    If you have two UserForms with textboxes, then you can refer to the textbox on the other form from within the form module as follows: -

    TextBox1.Text= UserForm2.TextBox.Text

    If that doesn't help, consider hiving off anything that deals with variables into a normal module procedure, called in response to an event on your UserForm.

    As a simple example if you press command button 1 on your first UserForm, then call your procedure from that click event, assign the textbox value (say) to your variable and do your manipulation within the standard module. Hope that helps, if you post more specifics, then I could give you some more advice.

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    SRC
    Posts
    165
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    From what I understand you need to create a public variable in a module sheet and assign it to be equal to the text box then when the new user form is needed assign the text box in this to be equal to the public variable in the module.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •