Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:03:11+00:00 2026-05-26T14:03:11+00:00

I am creating a excel sheet that would autocomplete a text based on the

  • 0

I am creating a excel sheet that would autocomplete a text based on the text present in a particular column. After trying to make one myself unsuccessfully, I was looking online for sample codes that I could modify and incorporate in my program. (and not plagiarize)

I downloaded Workbook1.xls from http://www.ozgrid.com/forum/showthread.php?t=144438

The code is

Option Explicit

Dim ufEventsDisabled As Boolean
Dim autoCompleteEnabled As Boolean
Dim oRange As Range

Private Sub TextBox1_Change()
    If ufEventsDisabled Then Exit Sub
    If autoCompleteEnabled Then Call myAutoComplete(TextBox1)
End Sub

Sub myAutoComplete(aTextBox As MSForms.TextBox)
    Dim RestOfCompletion As String
    On Error GoTo Halt
    With aTextBox
        If .SelStart + .SelLength = Len(.Text) Then
            RestOfCompletion = Mid(oRange.Cells(1, 1).AutoComplete(.Text), Len(.Text) + 1)
            ufEventsDisabled = True
            .Text = .Text & RestOfCompletion
            .SelStart = Len(.Text) - Len(RestOfCompletion)
            .SelLength = Len(RestOfCompletion)
        End If
    End With
Halt:
ufEventsDisabled = False
On Error GoTo 0
End Sub

Private Sub TextBox1_AfterUpdate()
    Dim strCompleted As String
    With TextBox1
        strCompleted = oRange.AutoComplete(.Text)
        If LCase(strCompleted) = LCase(.Text) Then
            ufEventsDisabled = True
            .Text = strCompleted
            ufEventsDisabled = False
        End If
    End With
End Sub

Private Sub TextBox1_Enter()
    Set oRange = ThisWorkbook.Sheets("Sheet1").Range("f4")
End Sub

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    autoCompleteEnabled = KeyCode <> vbKeyBack
    autoCompleteEnabled = ((vbKey0 <= KeyCode) And (KeyCode <= vbKeyZ))
End Sub

Private Sub CommandButton1_Click()
    Unload Me
End Sub

Private Sub UserForm_Click()

End Sub

If you’d notice the line RestOfCompletion = Mid(oRange.Cells(1, 1).AutoComplete(.Text), Len(.Text) + 1), I was wondering what AutoComplete is doing here. Its not a in built function and is not defined anywhere. Still the code runs fine. I am very curious.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:03:12+00:00Added an answer on May 26, 2026 at 2:03 pm

    The .AutoComplete is a function of the Range object – it is based on passing the text to a range that exists elsewhere on the sheet.

    You can see the documentation on this function here:
    http://msdn.microsoft.com/en-us/library/bb209667(v=office.12).aspx

    The myAutoComplete function handles the finding of the autocomplete data against the range if it exists, and the other pieces in the code are for highlighting the correct piece of text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read one excel sheet and then creating another excel sheet
I am creating a C# windows application to create an Excel 2003 sheet. There
What column names cannot be used when creating an Excel spreadsheet with ADO. I
I'm creating a calendar in excel. Column 1 is 01.01.2010 (dd.MM.yyyy), Column 2 is
I've a requirement that I need to read an excel sheet programmatically using asp.net/C#
I'm trying to create a multi-sheet excel document, and thus far I'd been doing
Possible Duplicate: python: creating excel workbook and dumping csv files as worksheets How would
I trying to make automatic variables available to Excel VBA (like ActiveSheet or ActiveCell)
I am creating a pivot table excel sheet in my ASP .NET web application
I have an Excel sheet with first names in Column A and surnames in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.