Excel Data Validation Combo Box Click
Excel Data Validation Combo Box Click
http://www.contextures.com/xlDataVal14.html
Home RSS
Excel Tips
Excel Files
Products
Blog
Contact
Create an Excel Data Validation Dropdown List Add the Combo box Open the Properties Window Change the Combo box Properties Exit Design Mode Add the Code Test the Code Download the zipped sample file
You can use Excel Data Validation to create a dropdown list of options in a cell. However, the list font can't be changed, nor can the number of visible rows, which has a maximum of eight. 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. Click on a cell that contains a data validation list, and the combo box appears. The combo box's font size can be set, more than 8 rows can be displayed, and autocomplete can be enabled. If you would prefer to see the combo box only when you double-click on a data validation cell, please use the instructions at one of the following pages: Data Validation -- Combo Box Data Validation -- Combo Box - Named Ranges Note: If the worksheet is protected, allow users to Edit Objects, and they will be able to use the combobox.
1 of 5
11/26/2013 9:25 PM
http://www.contextures.com/xlDataVal14.html
2 of 5
11/26/2013 9:25 PM
http://www.contextures.com/xlDataVal14.html
Change the Font and Font Size 1. In the Properties window, click in the Font property, and click the ... button 2. In the Font dialog box, select a font, font size, and other settings that you want for your combo box.
3. Click OK
3 of 5
11/26/2013 9:25 PM
http://www.contextures.com/xlDataVal14.html
With cboTemp .Top = 10 .Left = 10 .ListFillRange = "" .LinkedCell = "" .Visible = False .Value = "" End With End If On Error GoTo errHandler If Target.Validation.Type = 3 Then 'if the cell contains a data validation list 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 + 15 .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 exitHandler: Application.ScreenUpdating = True Application.EnableEvents = True Exit Sub errHandler: Resume exitHandler 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 '====================================
Performance Dashboards
Corporater.com/Perfor Build executive dashboards with KPIs, initiatives and more.See Demo
Self-Confidence Workshops Spreadsheet Professional Learn Macros for Excel Descriptive Stats Macro
To add this code to the worksheet: 1. Right-click on the sheet tab, and choose View Code. 2. Choose Edit | Paste, to paste the code onto the sheet module, where the cursor is flashing. 3. Choose File | Close and Return to Microsoft Excel.
4 of 5
11/26/2013 9:25 PM
http://www.contextures.com/xlDataVal14.html
Home
Excel Tips
Excel Files
Products
Blog
Contact
Privacy Policy
5 of 5
11/26/2013 9:25 PM