Assuming this is for a ComboBox that is located on a Worksheet not a UserForm (though adapting it for a UserForm would not be too difficult). This works for me in testing:
<font face=Courier New>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> ComboBox1_GotFocus()
<SPAN style="color:#00007F">Dim</SPAN> rngCell <SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#00007F">For</SPAN> i = Me.ComboBox1.ListCount - 1 <SPAN style="color:#00007F">To</SPAN> 0 <SPAN style="color:#00007F">Step</SPAN> -1
Me.ComboBox1.RemoveItem i
<SPAN style="color:#00007F">Next</SPAN> i
Put the code into your workbook_open event so the code will look like this:
'change the sheet1 to your sheet name that contains the combobox
'change the combobox1 to your combobox name if different
'change Sheet2 & 3 name to yours
'for reference Cells(7, 5) is equal to Cell E7 on Sheet2
Code:
Private Sub Workbook_Open()
Sheet1.ComboBox1.AddItem Sheet2.Cells(7, 5).Value
Sheet1.ComboBox1.AddItem Sheet3.Cells(6, 5).Value
End Sub
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.