Results 1 to 6 of 6

Thread: listbox populated with Vlookup from multiple worksheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    10
    Rep Power
    0

    listbox populated with Vlookup from multiple worksheet

    Hello VBA Guru,
    i am newby to VBA.i have Excel file with 3 user forms (file attached). i have managed to work out most of functions by learning VBA through different forums and youtube. i am stuck to create below formula that will finish my form.
    looking for help to create formulas for (i have tried many but nothing works)
    1) copy selected items from listbox 1 (lstdatabase, userform3) to listbox 2 (lstdatabse1, useform1). i am able to copy required column from lstdatabase to lstdatabse1. however, i would like to add additional column to lstdatabse1(userform1) from different sheet (cost, cost1 , cost2) in workbook by referencing part number column 3 of lstdatabse1. i have tried Vlookup but somehow it not working (highlighted in red). please refer below code i used for this extercise. please suggest modification or provide your input to make it work.
    Code:
    Private Sub cmdcostupdates_Click()
    With UserForm1.lstdatabase1
    
            .ColumnCount = 10
            .ColumnHeads = True
            .ColumnWidths = "40,60,60,60,60,100,100,250,80,80"
    
    
    Dim i As Integer
    For i = 0 To UserForm3.lstDatabase.ListCount - 1
    
        If UserForm3.lstDatabase.Selected(i) = True Then
         UserForm1.lstdatabase1.AddItem
         UserForm1.lstdatabase1.Column(0, (UserForm1.lstdatabase1.ListCount - 1)) = UserForm3.lstDatabase.Column(0, i)
         UserForm1.lstdatabase1.Column(1, (UserForm1.lstdatabase1.ListCount - 1)) = UserForm3.lstDatabase.Column(1, i)
         UserForm1.lstdatabase1.Column(2, (UserForm1.lstdatabase1.ListCount - 1)) = UserForm3.lstDatabase.Column(2, i)
         UserForm1.lstdatabase1.Column(3, (UserForm1.lstdatabase1.ListCount - 1)) = UserForm3.lstDatabase.Column(3, i)
         UserForm1.lstdatabase1.Column(4, (UserForm1.lstdatabase1.ListCount - 1)) = UserForm3.lstDatabase.Column(4, i)
         'UserForm1.lstdatabase1.Column(6, (UserForm1.lstdatabase1.ListCount - 1)) = Application.WorksheetFunction.VLookup(UserForm1.lstdatabase1.Column(3, i), Sheets("cost").Range("A1:G1000"), 7, False)
         'UserForm1.txtcurrentprice3.Value = Application.WorksheetFunction.VLookup(UserForm1.lstdatabase1.Value("Selection.Row;3"), Sheets("cost").Range("A1:G1000"), 7, False)
        End If
    Next i
    
       
        UserForm1.Show
    End With
    
    End Sub
    thanks if advance for your time and help.

    i have posted this on other forum and pending any help.

    https://www.mrexcel.com/board/thread...ookup.1139401/
    https://www.dropbox.com/preview/Exce...?role=personal
    2) once, lstdatabse1 populated with column 4 (from cost tab),5 (from cost1 tab) and 6 (from cost2 tab), i would like to click on particular row in lstdatabase1 and userform1 textbox should automatic fill from values.
    Last edited by jay6939; 07-11-2020 at 05:27 AM. Reason: Code tags and repaired false red color in code

Similar Threads

  1. Vlookup on multiple matches
    By haiders7 in forum Excel Help
    Replies: 1
    Last Post: 08-10-2019, 05:08 PM
  2. Convert All Vlookup formulas to Index-Match in a worksheet
    By littleiitin in forum Download Center
    Replies: 0
    Last Post: 03-17-2016, 06:50 PM
  3. Vlookup - Multiple Sheets
    By Suhail in forum Excel Help
    Replies: 3
    Last Post: 01-30-2013, 06:47 PM
  4. Replies: 4
    Last Post: 08-14-2012, 03:17 AM
  5. VLOOKUP with Multiple Results
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 05-26-2011, 10:29 PM

Posting Permissions

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