VBA Combobox


This is a text and video example of how to implement a VBA Combobox:

On your Excel worksheet show your “Control Toolbar”. In Excel 2003 and prior, right click the standard toolbar (at the top of your screen) and choose “Control Toolbar”. In Excel 2007 and above click the round Microsoft Office Button at the top left or your screen. Then choose “Excel Options” at the bottom of the list. The choose “Developer” and select to show the developer toolbar.

Add combo box to your worksheet, then choose to show the properties. Key in “A1” for the linked cell. Call one of your worksheets “data”, and for “ListFillRange” enter “data!A2:A5” (that’s the naming structure [worksheet name]![cell range]). Make sure you enter some values into the sheet called “data” and cells “A2-A5” or else you won’t show anything in your new combobox.
This is what your worksheet should look like:
Cell A2 = “red”
Cell A3 = “blue”
Cell A4 = “black”
Cell A5 = “yellow”
Next – add some code to the “Change” event of the combobox. You will analyze the value of the changed item in the combobox.

It’s going to look like this, and you’ll have to apply the principles to your situation:
*******************************************************************

Private Sub cboColors_Change()
   Dim strColor As String

   strColor = Me.cboColors
   strColor = Trim(strColor)

   Select Case strColor
      Case "blue"
         MsgBox "blue"
      Case "black"
         MsgBox "black"
      Case Else
         MsgBox Me.cboColors
      End Select
   End Sub	

*********************************************************************
Now watch how it’s done…

Let me know if you have any questions

[simple_contact_form]