Results 1 to 5 of 5

Populate textboxes from listbox.click

Threaded View

  1. #1
    Registered User
    Join Date
    05-03-2012
    Location
    South London
    MS-Off Ver
    Excel 2010
    Posts
    10

    Populate textboxes from listbox.click

    Hi guys

    I have been trying to populate a listbox using option buttons then click on the listbox to do a vlookup and populate 4 textboxes. When I open the userform and click on any of the option buttons the listbox populates correctly and so do the textboxes when I click on the listbox item, however when I click on another option button I get an error. First thought was to clear the listbox but this also creates an error.

    The option buttons represent 11 different worksheets and the listbox are names taken from those sheets, then use the name to populate the textboxes with info from vlookup.

    Private Sub optBowser_Change()
    
    Dim rng As Range
    Dim LastRow As Long    
       
        With Sheets("Bowser")
            LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
            Set rng = .Range(.Cells(4, 1), .Cells(LastRow, 1))
        End With
            
            frmAnnualLeave.lstNames.Clear
            
        With Me.lstNames
                   
                   .RowSource = rng.Address(external:=True)
            
        End With
    
    End Sub
    
    Private Sub lstNames_Click()
    If optBowser.Value = True Then
    
        txtEntitlement.Value = Application.WorksheetFunction.VLookup(Me.lstNames.Value, Sheets("Bowser").Range("A4:E8"), 2, False)
        txtAvailable.Value = Application.WorksheetFunction.VLookup(Me.lstNames.Value, Sheets("Bowser").Range("A4:E8"), 3, False)
        txtSick.Value = Application.WorksheetFunction.VLookup(Me.lstNames.Value, Sheets("Bowser").Range("A4:E8"), 4, False)
        txtFTJ.Value = Application.WorksheetFunction.VLookup(Me.lstNames.Value, Sheets("Bowser").Range("A4:E8"), 5, False)
        
        End If
    End Sub
    Hope you can understand where Im going with this and any help would be appreciated.

    wingnut74

    Moderator's note: I have added code tags because it's your first post. Please take the time to review our rules. There aren't many, and they are all important. --6StringJazzer
    Last edited by 6StringJazzer; 12-30-2013 at 02:02 PM. Reason: code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Populate textboxes from listbox item cellrow to modifie cellvalue and send it back to exce
    By prohmex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-18-2013, 06:43 PM
  2. Userform populate listbox with search from multiple textboxes
    By chendysworld in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 11:12 AM
  3. [SOLVED] Populate listbox columns with entries from textboxes on userform
    By AndyE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 11:05 PM
  4. Listbox click in search won't populate previously chosen checkboxes
    By Kristengeyer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2011, 04:18 PM
  5. Prevent ListBox Click Event Until Mouse Click
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 12:23 PM

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