Creating listboxes which are interdependent

SamirBhowmik

New Member
Joined
Sep 23, 2021
Messages
26
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hello,
I have around 10 listboxes placed in an userform where the data in each listbox are inter-related. (a screenshot of the userform is attached). I would like to link all the listboxes as in any change in any listbox should only keep the relevant data in the other listboxes. I have managed to do the same with listbox1 and listbox2 where changes in listbox1 would keep the corresponding data in listbox2 with the help of @DanteAmor. below is the code:
VBA Code:
Private Sub ListBox1_Change()
  Dim a() As Variant
  Dim dic As Object
  Dim i As Long, j As Long
 
  Set dic = CreateObject("Scripting.Dictionary")
  a = Sheets("MDB").Range("A2", Sheets("MDB").Range("M" & Rows.Count).End(3)).Value
 
  ListBox2.Clear
  With ListBox1
    For i = 0 To .ListCount - 1
      If .Selected(i) Then
        For j = 1 To UBound(a, 1)
          If a(j, 1) = .List(i) Then
            dic(a(j, 3)) = Empty
          End If
        Next
      End If
    Next
    If dic.Count > 0 Then ListBox2.List = Application.Transpose(dic.keys)
  End With
End Sub

What I want to achieve is that for example any change in listbox2 or listbox3, listbox4 etc. will keep only the corresponding data in all the other listboxes and all the listboxes should have this feature
I am quite new to vba and with the help of this community I will be able to learn it well.

Thank you
 

Attachments

  • Capture 2 listbox.JPG
    Capture 2 listbox.JPG
    92 KB · Views: 23

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Could anyone help me with the above post please. I still couldn't figure out a solution for the requirement. Thank you
 
Upvote 0
Could anyone help me with the above post please. I still couldn't figure out a solution for the requirement. Thank you
Is anyone there who could help me with the issue above mentioned ? I still couldn't figure out the exact structure of code to implement even after multiple forum references and searches. Please I request the members of this forum to come forward and lend me a helping hand for the requirement above...
 
Upvote 0

Forum statistics

Threads
1,214,524
Messages
6,120,049
Members
448,940
Latest member
mdusw

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