LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default autocomplete

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autocomplete Alex Garner Excel Discussion (Misc queries) 2 March 1st 09 06:23 PM
AutoComplete Nicola Excel Worksheet Functions 6 October 3rd 06 09:29 PM
VBA Autocomplete [email protected] Excel Discussion (Misc queries) 0 January 11th 06 05:01 PM
Using autocomplete njamy Excel Worksheet Functions 1 July 22nd 05 09:40 PM
Autocomplete Possible? R Doornbosch Excel Programming 1 February 5th 04 12:10 AM


All times are GMT +1. The time now is 06:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"