+ Reply to Thread
Results 1 to 7 of 7

Pass Userform Values into VBA

  1. #1
    Registered User
    Join Date
    10-13-2010
    Location
    Malvern, AR
    MS-Off Ver
    Excel 2003
    Posts
    49

    Pass Userform Values into VBA

    Hey guys

    I have 2 userform text boxes (One that has a username, another has a password) That I want to be passed into excel to equal variables. How would I go about assigning these to variables in VBA for a macro to use?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,290

    Re: Pass Userform Values into VBA

    A very simple example:

    Please Login or Register  to view this content.


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Pass Userform Values into VBA

    You could put this in the userform's code module
    Please Login or Register  to view this content.
    and code like this in a normal module

    Please Login or Register  to view this content.
    Alternatly, you could put much of the machinery inside the userform code module
    Please Login or Register  to view this content.
    and call it from a normal module. These two subs show different ways of calling the UserAndPassword function.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    10-13-2010
    Location
    Malvern, AR
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Pass Userform Values into VBA

    I do not know if I explained it like I wanted to. Here it is again:

    I have one Forms.TextBox.1 named Username
    I have one Forms.TextBox.1 name Password

    How do I take the text in these boxes transfer over to variables that I can use in VBA code?

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

    Re: Pass Userform Values into VBA

    So in what way do the answers not apply?
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Registered User
    Join Date
    10-13-2010
    Location
    Malvern, AR
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Pass Userform Values into VBA

    I do not think I understand how any of them work.

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

    Re: Pass Userform Values into VBA

    It might help if you posted a sample workbook showing what you are trying to do, then we could provide specific code with an explanation.

+ 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