+ Reply to Thread
Results 1 to 2 of 2

VBA code to display 'password' store in cells

  1. #1
    Registered User
    Join Date
    11-25-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    1

    VBA code to display 'password' store in cells

    I have two columns of data. The first contains 'names' and the second contains 'passwords'. The Userform is completed with information plus a combobox displaying 'names'. When the command button is clicked, the information is updated to a database and the 'name' selected in the combobox should display the matching 'password' on a message box.

    The question is how do I code the combobox element of the userform to display on a message box, the 'password' matching the 'name' selected?

  2. #2
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    314

    Re: VBA code to display 'password' store in cells

    Hi mosesena

    It seems like you have two distinct problems - the first is displaying the password for a name, and the second is something to do with updating the place where these items are stored. The first part is pretty easy to do, the second will, I suspect, require some more input from you.

    Let's take a look at the first part.

    We'll have a spreadsheet where the Names are in Column "A", and the Passwords are in Column "B". You want to show the Names in a combobox, and when the user clicks on (selects) a name, you want to show a message box with the password, right?

    So, we need to load the combobox with two pieces of information. The first is the Name, and the second will be the password itself. However, we won't actually show the password in the combobox (although this is perfectly easy to do).

    You'll need a user form and the combobox. In the properties for the combobox set the ColumnCount property to 2.
    Then set the column widths to "144pt; 0pt". This will give you two columns, one of which is invisible.

    Then you'll use the following code to load up the combobox:
    Please Login or Register  to view this content.
    This will put all the names into the visible first column of the combobox, and all the passwords into the invisible second column!

    Then, you will add the following code for the Click event of the combobox. (I'm assuming you know how to do this. If not, let usknow, and we can explain in a little more detail)
    Please Login or Register  to view this content.
    Lastly, we need to load the combobox, and this is perhaps best done when the form is initialized:
    Please Login or Register  to view this content.
    So, the final code is this:
    Please Login or Register  to view this content.
    Now, having said all this, it is probably easier simply to make both columns of the combo box visible (set the ColumnWidths property to simply "144pt".

    And lastly, it's generally a pretty terrible idea to make passwords visible on a user form! You typically never want anyone other than the owner of a password to see what it is. To reset a password you clear it out, and then have other code somewhere that prevents the use of an empty password from being valid! However, that's another day, and another story!

    Hope this helps!

    Tony

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Highlight cell, display and store text
    By msverven in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2013, 08:53 AM
  2. Replies: 3
    Last Post: 06-27-2012, 05:47 PM
  3. Creating a grid to display store closings
    By aircad in forum Excel General
    Replies: 4
    Last Post: 06-06-2012, 10:19 AM
  4. display an error message if the textbox doesn't store time
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-16-2009, 04:42 AM
  5. Replies: 4
    Last Post: 06-07-2006, 03:50 AM

Tags for this Thread

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