UserForm ListBox

jthomas24

Board Regular
Joined
Jun 6, 2017
Messages
59
Hello

I have created a user form and it has a list box with about 7 columns and then there is 7 Labels. What i am trying to do now is when a row is selected in the list box, i want to Labels to show what is selected, and then constantly change when another option is selected from the list box. The labels start from 9 to 16.

Thank you
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
If I understand you correctly you have a Userform listbox named ??? I need the name
And you want the value from the row selected to be entered into your 7 labels named ???
So the value in column (1) goes to label1 the data in column (2) goes to label2 etc. etc.

It's important to keep your labels named label1 label2 label3 etc.

I will get back with you. But since you did not give me the name of the listbox I will go with listbox1
 
Upvote 0
Try this:

Assuming your Listbox is named "ListBox1"
And your listbox is a muticolumn ListBox with 7 columns.

Try this:

Code:
Private Sub CommandButton2_Click()
Dim i As Long
 
If ListBox1.ListIndex < 0 Then
MsgBox "You must select some row in the List Box"
Exit Sub
End If
   
    For i = 9 To 15
        Controls("Label" & i).Caption = ListBox1.List(, i - 9)
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,020
Members
452,542
Latest member
Bricklin

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