How to Select First Item from ComboBox Using VBA in Excel: 5 Methods

Method 1 – Create a Dataset with Proper Parameters

Create your list. We created a “List of Food” column with 8 items and another column with “Quantity Sold.” We created a ComboBox with the list of the first column. As a result, our dataset looks like this:

How to Select First Item from Combobox Using VBA in Excel


Method 2 – Open Microsoft Visual Basic Window

Open the Microsoft Visual Basic window.

  • Go to the Developer tab.
  • Press on Visual Basic from the ribbon.
  • Apply the keyboard shortcut  Alt+F11  to open the window.

How to Select First Item from Combobox Using VBA in Excel

  • The Microsoft Visual Basic window will appear.


Method 3 – Create ComboBox

Insert a new Userform and create a ComboBox.

  • Go to the Insert tab and select Userform.

Create ComboBox

  • A Userform window will open with a Toolbox. From the Toolbox, click Combobox.

Create ComboBox

  • Drag your cursor to create a ComboBox of your desired size.

Create ComboBox

  • Double-click inside the combobox to open a window to write codes.


Method 4 – Copy-Paste VBA Code

Need a VBA code to select the first item from the ComboBox.

  • Write the following VBA code or copy it from below and paste it into the window.
Private Sub ComboBox1_Change()
Me.ComboBox1.AddItem "Cookies"
Me.ComboBox1.AddItem "Chocolate"
Me.ComboBox1.AddItem "Coffee"
Me.ComboBox1.AddItem "Yogurt"
Me.ComboBox1.AddItem "Donuts"
Me.ComboBox1.AddItem "Croissant"
Me.ComboBox1.AddItem "Waffles"
Me.ComboBox1.ListIndex = 0
End Sub

How to Select First Item from Combobox Using VBA in Excel

  • If you want to change the name of the Userform, go to Properties and change the Caption.


Method 5 – Run VBA Code

Run the VBA code.

  • Click on the Run Macro button, or press  F5  on your keyboard to run the code.
  • The worksheet will open, and you will find a ComboBox.

How to Select First Item from Combobox Using VBA in Excel

  • Type anything in the combobox. It will just show the first item on the list.

How to Select First Item from Combobox Using VBA in Excel

  • If you try to select other items, it will still show the first item.

How to Select First Item from Combobox Using VBA in Excel

Notes
  • Insert the Userform instead of Module in the Microsoft Visual Basic window.
  • Write the item you want to be selected in the first place in the VBA code.

Download Practice Workbook

Download this practice workbook while you are reading this article.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Alif Bin Hussain
Alif Bin Hussain

Alif Bin Hussain earned a BSc in Civil Engineering from Bangladesh University of Engineering and Technology. As an engineering graduate, he has a deep passion for research and innovation. He loves to play with Excel. In his role as an Excel & VBA Content Developer at ExcelDemy, he not only solves tricky problems but also shows enthusiasm and expertise in handling tough situations with finesse, emphasizing his dedication to delivering top-notch content. He is interested in C, C++,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo