Hi,
Supposed I have a ComboBox with a dropdown list, which is based on a named range. The size of the dropdown list depends on the value selected in another ComboBox where I have value of 'region', 'district'. Usually district has bigger dropdown list than region. However, as I select 'region' first, which has 10 rows in the dropdown list; then if I select 'district', the dropdown will show only 10 rows of district and the rest (about 20) won't show.
Is there anyway of clearing all the dropdown before the second selection?
Here is the code behind the ComboBoxes.
Private Sub cmbSelectView_Change()
Dim CurrSheetName As String
Dim strSelection As String
Application.Calculate
CurrSheetName = ActiveSheet.Name
If CurrSheetName = "DataView" Then
On Error Resume Next
ActiveWorkbook.Names("Acct_NameRange").Delete
ActiveWorkbook.Names("TLN_NameRange").Delete
On Error GoTo 0
If strSelection = "District" Then
Sheets("Dist_tnlist").Range("A2").CurrentRegion.Name = "TLN_NameRange"
Sheets("distacctlist").Range("A2").CurrentRegion.Name = "Acct_NameRange"
ElseIf strSelection = "Region" Then
Sheets("Reg_tnlist").Range("A2").CurrentRegion.Name = "TLN_NameRange"
Sheets("regacctlist").Range("A2").CurrentRegion.Name = "Acct_NameRange"
End If
End If
End Sub
Thanks in advance.
Supposed I have a ComboBox with a dropdown list, which is based on a named range. The size of the dropdown list depends on the value selected in another ComboBox where I have value of 'region', 'district'. Usually district has bigger dropdown list than region. However, as I select 'region' first, which has 10 rows in the dropdown list; then if I select 'district', the dropdown will show only 10 rows of district and the rest (about 20) won't show.
Is there anyway of clearing all the dropdown before the second selection?
Here is the code behind the ComboBoxes.
Private Sub cmbSelectView_Change()
Dim CurrSheetName As String
Dim strSelection As String
Application.Calculate
CurrSheetName = ActiveSheet.Name
If CurrSheetName = "DataView" Then
On Error Resume Next
ActiveWorkbook.Names("Acct_NameRange").Delete
ActiveWorkbook.Names("TLN_NameRange").Delete
On Error GoTo 0
If strSelection = "District" Then
Sheets("Dist_tnlist").Range("A2").CurrentRegion.Name = "TLN_NameRange"
Sheets("distacctlist").Range("A2").CurrentRegion.Name = "Acct_NameRange"
ElseIf strSelection = "Region" Then
Sheets("Reg_tnlist").Range("A2").CurrentRegion.Name = "TLN_NameRange"
Sheets("regacctlist").Range("A2").CurrentRegion.Name = "Acct_NameRange"
End If
End If
End Sub
Thanks in advance.