Results 1 to 4 of 4

Tab into combobox with autocomplete drop down menu

Threaded View

  1. #1
    Registered User
    Join Date
    11-29-2016
    Location
    canada
    MS-Off Ver
    office 2016
    Posts
    2

    Tab into combobox with autocomplete drop down menu

    Hello,

    I have only just stared to delve into VBA coding and I have come across a problem that I cant seem to find an answer to yet. I am using a code I found online for creating and using a combox on top of a data validation menu that way it can be autocompleted when tabing into and out of cells while typing. This is for taking records over a CB radio about snow plow operations so the user needs to be able to type information fast and accurate. Right now it is set up to only activate when I double click the cell which is not efficient for data entry.

    The code that works for the comboboxes is as follows:

    '==========================
    Private Sub Worksheet_BeforedoubleClick(ByVal Target As Range, _
      Cancel As Boolean)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Set cboTemp = ws.OLEObjects("TempCombo")
      On Error Resume Next
      With cboTemp
      'clear and hide the combo box
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
      End With
    On Error GoTo errHandler
      If Target.Validation.Type = 3 Then
        'if the cell contains a data validation list
        Cancel = True
        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 + 5
          .Height = Target.Height + 5
          .ListFillRange = ws.Range(str).Address
          .LinkedCell = Target.Address
        End With
        cboTemp.Activate
        'open the drop down list automatically
        Me.TempCombo.DropDown
      End If
      
    errHandler:
      Application.EnableEvents = True
      Exit Sub
    
    End Sub
    '=========================================
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Set ws = ActiveSheet
    
    Set cboTemp = ws.OLEObjects("TempCombo")
      On Error Resume Next
    If cboTemp.Visible = True Then
      With cboTemp
        .Top = 10
        .Left = 10
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
        .Value = ""
      End With
    End If
    
    errHandler:
      Application.EnableEvents = True
      Exit Sub
    
    End Sub
    '====================================
    'Optional code to move to next cell if Tab or Enter are pressed
    'from code by Ted Lanham
    '***NOTE: if KeyDown causes problems, change to KeyUp
    
    Private Sub TempCombo_KeyDown(ByVal _
            KeyCode As MSForms.ReturnInteger, _
            ByVal Shift As Integer)
        Select Case KeyCode
            Case 9 'Tab
                ActiveCell.Offset(0, 1).Activate
            Case 13 'Enter
                ActiveCell.Offset(1, 0).Activate
            Case Else
                'do nothing
        End Select
    End Sub
    '====================================


    I am wondering if there is a way to tab into the combo box from the cell to the left enter the info and tab out into a generic cell and back into another combobox etc as needed.

    Cell A5 is where the records would start and I will have have the drop downs in colums B, C, D and G each with their own tables.

    Please let me know if any more information is needed or if I need to upload the workbook.

    Thanks,
    Last edited by jparry85; 11-29-2016 at 04:47 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Dynamic ComboBox (Drop down) menu in a VBA UserForm
    By igormigor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2015, 05:07 AM
  2. [SOLVED] AutoComplete TextBox or ComboBox
    By mkachwee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2012, 07:08 PM
  3. Autocomplete on combobox
    By Fr0sT in forum Excel General
    Replies: 4
    Last Post: 02-29-2012, 05:20 PM
  4. My user defined function doesn't show up in autocomplete drop down menu
    By wlan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2010, 09:56 AM
  5. [SOLVED] Drop down menu-How do you produce a drop down menu in a single cell in Excel
    By Freddo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-04-2006, 04:35 AM
  6. [SOLVED] AutoComplete - Forms Combobox
    By Sige in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-30-2005, 05:20 AM
  7. Replies: 2
    Last Post: 02-14-2005, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1