creating drop down box
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Creating Drop Down Box in Combo Box

Creating Drop Down Box in Combo Box

resolvedResolved · Medium Priority · Version 2007

replyReply Thu 16 Dec 2010, 15:49Delegate Sugi said...

Sugi has attended:
Excel VBA Intro Intermediate course

Creating Drop Down Box in Combo Box

When creating a drop down box in a combo box, can you do it without creating a List Page and instead from the data sheet?

For upcoming training course dates see: Pricing & availability

replyReply Fri 17 Dec 2010, 16:28Trainer Stephen said...

RE: Creating Drop Down Box in Combo Box

Hi Sugi

Thanks for your question

The procedure outlined below, writes unique values to an array from a specified column. You can then use the additem method of the combo box to add each item in the array to the combo box

Sub GetUniqueItems

Dim UniqueList() As String
Dim strCurrentItem As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim blnExists As Boolean

ReDim UniqueList(1)

blnExists = False

UniqueList(1) = Range("A1").Value
k = 2

For i = 2 To Range("A1").CurrentRegion.Rows.Count
blnExists = False
strCurrentItem = Range("a1").Cells(i, 1)
For j = 1 To UBound(UniqueList)
If UniqueList(j) = strCurrentItem Then
blnExists = True
Exit For
End If
Next j
If blnExists = False Then
ReDim Preserve UniqueList(k)
UniqueList(j) = strCurrentItem
blnExists = False
k = k + 1
End If
Next i

For j = 1 To UBound(UniqueList)
Debug.Print UniqueList(j)
Next j

End Sub

Fri 24 Dec 2010: Automatically marked as resolved.

 

Please browse our web site to find out more about
excel classes and other Microsoft training courses.

Excel tip:

Hide columns in an Excel 2010 Worksheet

If you don’t want part of the Excel worksheet to be visible or when you don’t want certain data to appear in print outs, then a simple solution is to temporarily hide a column or multiple columns.

Hiding a single column:

1)Right click on the column header of the column you want to hide (this is the grey bar along the top edge of the worksheet)
2)Choose Hide from the menu
3)This column will now be hidden from view

Hide more than one column:

1)In the column header drag select to highlight the columns you want hidden
2)Right click and choose Hide from the menu

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard