Changing the Rowsource of a userform Listbox with each change in the Listbox selection

chazrab

Well-known Member
Joined
Oct 21, 2006
Messages
911
Office Version
  1. 365
Platform
  1. Windows
I'm trying to write a code block that would change the Rowsource property of a userform listbox for each change of the Listbox selection. Something like this:
Code:
Select case m.
Case Is = "Isaiah 25:8"
ListBox2.RowSource = Sheets("PROPHLINKS2").Range("A1:T1")

'Case Is = "Isaiah 26:19"
'ListBox2.RowSource = Sheets("PROPHLINKS2").Range("A2:T2")
...
End Select

Both the Change Event and the Click Event must refer to and use the Rowsource in the selected Case statement - that is the current Listbox selected value. So the Rowource would change with each change in the selected value of the Listbox. Below is the sheet data.
Row data for some rows extends out to but not past column T.

I ‘m initially placing the Select Case End Select in the Userform Activate Event.
This Click Event code would use the correct Rowsource of the Listbox selection:
Code:
Private Sub ListBox2_Click()
Dim n As Long
n = ListBox2.ListIndex
TextBox1.Value = ListBox2.List(n, 0) _
& vbCrLf + ListBox2.List(n, 1) _
& vbCrLf _
& ListBox2.List(n, 2) _
& vbCrLf _
& vbCrLf + ListBox2.List(n, 3) 
...
End Sub
Not sure of exactly where to put the Select End Select case statement.
Any help would be very appreciated.
Thanks, cr
 

Attachments

  • SHEET DATA.png
    SHEET DATA.png
    81 KB · Views: 21
  • USERFORM .png
    USERFORM .png
    196 KB · Views: 20

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,152
Messages
6,170,389
Members
452,323
Latest member
GoJones

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