Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel data validation with suggestions/autocomplete

Tags:

Apologies for my low level of Excel understanding, maybe what I am looking to do is not possible.

I have a list of 120 entries that I want to use as data validation. But instead of people having to scroll down the 120 options it would be great if they can start typing and see the options that could match what they are willing to write. Kind of like in autocomplete, I have found this tip.

I would like to have more options when the typing starts.

For example this would be a part of the list:

Awareness   Education   Budget   Budget Planning   Enterprise Budget  

When typing "B" I would like the three last options to appear and to click one of them. I don't know if there is a way of include vlookup in here...

Ideally the perfect thing would be to have several "tags" in one cell, but I fear that is absolutely impossible with excel.

Thank you very much for any input and sorry if I haven't explained myself properly.

like image 340
gcv Avatar asked Nov 06 '13 16:11

gcv


People also ask

How can I add AutoComplete to an Excel drop down validation?

Press Alt + Q keys simultaneously to close the Microsoft Visual Basic Applications window. From now on, when click on a drop down list cell, the drop down list will prompt automatically. You can start to type in the letter to make the corresponding item complete automatically in selected cell.

How do you use AutoComplete in Data Validation?

Also, Data Validation doesn't have an AutoComplete feature, which finds matching items in the list as you start to type. To overcome these limitations, you can add a combo box to your worksheet, and use programming to make it appear in cells that contain a data validation list.

Can Excel AutoFill from drop-down list?

Dropdown lists are a handy way to make data entry and validation more efficient in Excel. We've now added AutoComplete functionality, which automatically compares the text typed in a cell to all items in the dropdown list and displays only the items that match.


2 Answers

ExtendOffice.com offers a VBA solution that worked for me in Excel 2016. Here's my description of the steps. I included additional details to make it easier. I also modified the VBA code slightly. If this doesn't work for you, retry the steps or check out the instructions on the ExtendOffice page.

  1. Add data validation to a cell (or range of cells). Allow = List. Source = [the range with the values you want for the auto-complete / drop-down]. Click OK. You should now have a drop-down but with a weak auto-complete feature.

enter image description here

  1. With a cell containing your newly added data validation, insert an ActiveX combo box (NOT a form control combo box). This is done from the Developer ribbon. If you don't have the Developer ribbon you will need to add it from the Excel options menu.

enter image description here

  1. From the Developer tab in the Controls section, click "Design Mode". Select the combo box you just inserted. Then in the same ribbon section click "Properties". In the Properties window, change the name of the combo box to "TempCombo".

enter image description here

  1. Press ALT + F11 to go to the Visual Basic Editor. On the left-hand side, double click the worksheet with your data validation to open the code for that sheet. Copy and paste the following code onto the sheet. NOTE: I modified the code slightly so that it works even with Option Explicit enabled at the top of the sheet.

    Option Explicit  Private Sub Worksheet_SelectionChange(ByVal target As Range) 'Update by Extendoffice: 2018/9/21 ' Update by Chris Brackett 2018-11-30  Dim xWs As Worksheet Set xWs = Application.ActiveSheet  On Error Resume Next  Dim xCombox As OLEObject Set xCombox = xWs.OLEObjects("TempCombo")  ' Added this to auto select all text when activating the combox box. xCombox.SetFocus  With xCombox     .ListFillRange = vbNullString     .LinkedCell = vbNullString     .Visible = False End With   Dim xStr As String Dim xArr   If target.Validation.Type = xlValidateList Then     ' The target cell contains Data Validation.      target.Validation.InCellDropdown = False       ' Cancel the "SelectionChange" event.     Dim Cancel As Boolean     Cancel = True       xStr = target.Validation.Formula1     xStr = Right(xStr, Len(xStr) - 1)      If xStr = vbNullString Then Exit Sub      With xCombox         .Visible = True         .Left = target.Left         .Top = target.Top         .Width = target.Width + 5         .Height = target.Height + 5         .ListFillRange = xStr          If .ListFillRange = vbNullString Then             xArr = Split(xStr, ",")             Me.TempCombo.List = xArr         End If          .LinkedCell = target.Address      End With      xCombox.Activate     Me.TempCombo.DropDown  End If End Sub  Private Sub TempCombo_KeyDown( _                 ByVal KeyCode As MSForms.ReturnInteger, _                 ByVal Shift As Integer)     Select Case KeyCode         Case 9  ' Tab key             Application.ActiveCell.Offset(0, 1).Activate         Case 13 ' Pause key             Application.ActiveCell.Offset(1, 0).Activate     End Select End Sub 
  2. Make sure the the "Microsoft Forms 2.0 Object Library" is referenced. In the Visual Basic Editor, go to Tools > References, check the box next to that library (if not already checked) and click OK. To verify that it worked, go to Debug > Compile VBA Project.

  3. Finally, save your project and click in a cell with the data validation you added. You should see a combo box with a drop-down list of suggestions that updates with each letter you type.

enter image description here

enter image description here

like image 94
ChrisB Avatar answered Sep 24 '22 10:09

ChrisB


If you don't want to go down the VBA path, there is this trick from a previous question.

Excel 2010: how to use autocomplete in validation list

It does add some annoying bulk to the top of your sheets, and potential maintenance (should you need more options, adding names of people from a staff list, new projects etc.) but works all the same.

like image 25
Trigger-Cut Avatar answered Sep 20 '22 10:09

Trigger-Cut