Archive

Archive for the ‘VBA’ Category

Excel Populate a Combo Box from a Database

April 18th, 2012 5 comments

To populate a combo box on a userform in Excel you need to use VBA. Firstly add a combo box to a userform in the VBA window (Alt-F11) of your spreadsheet.

The VBA code below shows how to populate a 2 column combo box. Add this code to the Userform Initialize event to populate the combo box when the form is loaded.

You might need to add a Reference to make the ADODB part of this work. Go to Tools – References in the VBA window and find the highest number Microsoft ActiveX Data Objects 2.X Library. Select the highest 2.X library.


Read more…

Categories: Excel, VBA Tags: , , , ,

Excel VBA Select a Sheet

April 17th, 2012 No comments

To select a sheet in Excel using VBA use the following syntax: Sheets(“Sheetname”).select

Categories: Excel, VBA Tags: ,