D
Dantz
is there a way to create my own autocomplete that the list of strings
are from user inputs? please help me..as of my research I accidentally
got this code but it was really hard to modify esp. the
application.onkey...
Option Explicit
Dim i As Long
--------------------------------------------------------------------------------
Sub KeyEventOn()
For i = 65 To 90
Application.OnKey "{" & i & "}", "'MyValidation """ & i & """'"
Next
End Sub
--------------------------------------------------------------------------------
Sub KeyEventOff()
For i = 64 To 90
Application.OnKey "{" & i & "}"
Next
End Sub
--------------------------------------------------------------------------------
Sub MyValidation(ByVal KeyCode As Long)
Dim strText As String, strList As String
If Not TypeOf Selection Is Range Then Exit Sub
strText = Selection.Value & Chr(KeyCode)
strList = MakeArr(strText)
Selection.Value = strText
If strList = "False" Then
Selection.Validation.Delete
Else
With Selection.Validation
.Delete
.Add 3, 1, 1, Formula1:=strList
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
End With
End If
End Sub
--------------------------------------------------------------------------------
Function MakeArr(ByVal strChr As String) As String
Dim a As Variant
a = [MyList].Value
For i = LBound(a) To UBound(a)
If InStr(1, a(i, 1), strChr, vbTextCompare) = 1 Then
MakeArr = MakeArr & a(i, 1) & Chr(&H2C)
End If
Next
If MakeArr <> "" Then
MakeArr = Left(MakeArr, Len(MakeArr) - 1)
Else
MakeArr = "False"
End If
End Function
are from user inputs? please help me..as of my research I accidentally
got this code but it was really hard to modify esp. the
application.onkey...
Option Explicit
Dim i As Long
--------------------------------------------------------------------------------
Sub KeyEventOn()
For i = 65 To 90
Application.OnKey "{" & i & "}", "'MyValidation """ & i & """'"
Next
End Sub
--------------------------------------------------------------------------------
Sub KeyEventOff()
For i = 64 To 90
Application.OnKey "{" & i & "}"
Next
End Sub
--------------------------------------------------------------------------------
Sub MyValidation(ByVal KeyCode As Long)
Dim strText As String, strList As String
If Not TypeOf Selection Is Range Then Exit Sub
strText = Selection.Value & Chr(KeyCode)
strList = MakeArr(strText)
Selection.Value = strText
If strList = "False" Then
Selection.Validation.Delete
Else
With Selection.Validation
.Delete
.Add 3, 1, 1, Formula1:=strList
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
End With
End If
End Sub
--------------------------------------------------------------------------------
Function MakeArr(ByVal strChr As String) As String
Dim a As Variant
a = [MyList].Value
For i = LBound(a) To UBound(a)
If InStr(1, a(i, 1), strChr, vbTextCompare) = 1 Then
MakeArr = MakeArr & a(i, 1) & Chr(&H2C)
End If
Next
If MakeArr <> "" Then
MakeArr = Left(MakeArr, Len(MakeArr) - 1)
Else
MakeArr = "False"
End If
End Function