|
-
Jun 29th, 2019, 08:49 AM
#1
Thread Starter
Member
-
Jun 29th, 2019, 06:29 PM
#2
Re: USER FORM : ListBox population based on another ListBox value selection [VBA]
assuming that the order set are in order in the list box you can use the index of the first listbox to specify the column for the data
Code:
Private Sub ComboBox1_Click()
popnxtlist ComboBox1.ListIndex
End Sub
Sub popnxtlist(i As Integer)
dim r as range
set r = Range("g3").Offset(, i).Address
MsgBox r.address
' populate the next listbox from the data below r
note i used a combobox but a listbox would be the same
the popnxtlist can be used generically for any number of listboxes, by passing the target listbox with the listindex as a second parameter
eg if you had 4 or 5 cascading, each filled from the value selected in the previous one this procedure would save writing the code multiple times for each list box
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 1st, 2019, 02:37 AM
#3
Thread Starter
Member
Re: USER FORM : ListBox population based on another ListBox value selection [VBA]
@wetconn1 Working fine as usual . Thanks a lot.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|