Results 1 to 5 of 5

Setting Global Variable from a UserForm

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2009
    Location
    Darien, IL
    MS-Off Ver
    Excel 2003
    Posts
    4

    Setting Global Variable from a UserForm

    Hi everyone,

    I have a UserForm that runs when my excel project starts that prompts the user for two pieces of data: a username and a password (these are not for logging into the file itself, I need to use them to call web queries later). I want the UserForm to store both of these data in global variables, so that macros that are run in the future can refer to them and read their values. Unfortunately, I am very new to VBA and I cannot figure out what code I need and where exactly I need to put it. Here is my current code, where "authentication" is the name of the UserForm object, and the textboxes I use for entry are named "user" and "pass":

    In "This Workbook"
    Private Sub Workbook_Open()
    
    authentication.Show
    
    End Sub
    In "authentication"
    Private Sub submit_Click()
    
    ' Put a bunch of labels on cells
    
    globalVarUsername = user
    GlobalVarPassword = pass
    
    authentication.Hide
    
    End Sub
    Last edited by agwright; 08-14-2009 at 11:56 AM.

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