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!!!!
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!!!!