Dear all,
I have an userform in excel that has two listboxes.
The first one called 'lstRegion' displays the list of 3 regions (Region AA, BENELUX, Region C) which group different countries.
The second list box called 'lstCountry' displays some countries which can be part of one of the region in 'lstRegion'.
The user can select/deselect multiple records in 'lstRegion' and automatically, by the Change event, the countries belonging to the selected country will get selected/deselected.
The above features works by the below code:
Now, what I would like to do, Is also the way around: user can also select/deselect one or more countries and automatically the related region will get selected/deselected
For you reference you can download the file from here in order to discuss with you have to fix
Thankx
I have an userform in excel that has two listboxes.
The first one called 'lstRegion' displays the list of 3 regions (Region AA, BENELUX, Region C) which group different countries.
The second list box called 'lstCountry' displays some countries which can be part of one of the region in 'lstRegion'.
The user can select/deselect multiple records in 'lstRegion' and automatically, by the Change event, the countries belonging to the selected country will get selected/deselected.
The above features works by the below code:
VBA Code:
Private Sub lstRegion_Change()
Dim i As Long
lstRegionChangedList = True
lstCountryChangedList = False
SelectedItemsCountRegion = 0
If lstCountryChangedList = False Then
SelectDeselectCountryFromRegion lstRegion, lstCountry
lstRegionChangedList = False
End If
For i = 0 To lstRegion.ListCount - 1
If lstRegion.Selected(i) = True Then
SelectedItemsCountRegion = SelectedItemsCountRegion + 1
' If SelectedItemsCountRegion > 0 Then
' Exit For
' End If
End If
Next i
If SelectedItemsCountRegion = 0 Then
chkRegion_Select_Deselect_All.Caption = "SELECT ALL"
chkRegion_Select_Deselect_All.Value = False
ElseIf SelectedItemsCountRegion = lstRegion.ListCount Then
chkRegion_Select_Deselect_All.Value = True
End If
If SelectedItemsCountRegion > 0 And SelectedItemsCountCountry > 0 Then
cmdFind.Enabled = True
Else
cmdFind.Enabled = False
End If
End Sub
Private Sub chkCountry_Select_Deselect_All_Click()
chkCountry_Select_Deselect_All.Caption = IIf(chkCountry_Select_Deselect_All.Value = True, "DESELECT ALL", "SELECT ALL")
cmdFind.Enabled = chkCountry_Select_Deselect_All.Value
SelectDeselectAllItemsListBox lstCountry, chkCountry_Select_Deselect_All.Value
End Sub
Now, what I would like to do, Is also the way around: user can also select/deselect one or more countries and automatically the related region will get selected/deselected
For you reference you can download the file from here in order to discuss with you have to fix
Thankx