From a Userform Listbox of search results click a result to open Main Userform

markw1804

New Member
Joined
Nov 19, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

More of a question as to if this is possible as I cant get my head round it. I have a userform that allows searches for various items and works without issue. I am now trying to incorporate the code that on double click of the a row result in the listbox it then opens the Main Userform and populates all the fields.
Where I am struggling is that the Search listbox only displays 4 of the columns, but the main userform has 35 textboxes. I have seen examples of code for moving the listbox results to the userform but not sure how to get the whole row to effectively populate the userform.

VBA Code:
Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Load UserForm2
UserForm2.TextBox1 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 0)
UserForm2.TextBox2 = UserForm1.ListBox2.List(UserForm1.ListBox2.ListIndex, 1)

I have populate form code that works on the spin buttons that i thought I may be able to incorporate
This is an extract:
VBA Code:
Private Sub PopulateForm(SelectedRow As Range)

        With SelectedRow
    
txtItemNo.Value = .Cells(1, 1).Value
txtLocation.Value = .Cells(1, 2).Value

The first column on the list box results is a unique product code so could it be used to then lookup and grab the row information,
Am I over thinking it?

Your help and guidance as always is much appreciated.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top