Autocomplete dependent data validation drop down lists

GUSTAVOHELP

New Member
Joined
Oct 18, 2018
Messages
1
Dear Friends,

I was trying to find this all over the internet but the ones that I found does not work in my worksheet.
The idea is to include a VBA coding in order to include the autocomplete feature in all the Data Validation Dropdown Lists that I have included in the worksheet.

I found this coding in the internet and it works but with data validation dropdown lists that are no dependent, with the ones that I have it does not show anything in the dropdown list.

For dependent data validation dropdown lists I am using:

=IF(B12="",SectList,A12) for the first dropdown list and
=OFFSET(SectStart, MATCH(A12, SectColumn, 0) -1, 1, COUNTIF(SectColumn,A12), 1) for the second drowdown list

The code is:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Dim str As String
Dim cboTemp As OLEObject


With ActiveSheet


Set cboTemp = .OLEObjects("cboTemp")
With cboTemp
'clear and hide the combo box
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With

On Error GoTo ErrorRoutine
If Target.Validation.Type = 3 Then
'if the cell contains a data validation list
Application.EnableEvents = False
'get the data validation formula
str = Target.Validation.Formula1
str = Right(str, Len(str) - 1)
With cboTemp
'show the combobox with the list
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 15
.Height = Target.Height + 5
.ListFillRange = str
.LinkedCell = Target.Address
End With
cboTemp.Activate
'open the drop down list automatically
Me.cboTemp.DropDown
End If
Application.EnableEvents = True
Exit Sub
End With
ErrorRoutine:
Application.EnableEvents = True
Exit Sub
End Sub

Can somebody help me with this, I will really appreciate it a lot!!!!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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