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.
thanks if advance for your time and help.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
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.


Reply With Quote
Bookmarks