Solved

Excel comboboxes and their sources using vba

Posted on 2007-03-23
3
170 Views
Last Modified: 2010-04-30
I created a drop down list with the source as:
=OFFSET($AQ$1,0,0,COUNTA($AQ:$AQ),1)

A buddy of mine created a user form that also had drop down lists, but he used:
With ComboBox1
    .AddItem "Code"
    .AddItem "Cusip"
    .AddItem "Security Name"
End With

How do I set up the combobox so that it uses a source. I do not want to have to update this additem list everytime there is another item.  




0
Comment
Question by:tiehaze
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
p912s earned 500 total points
ID: 18782804
A combobox on a user form?

Assuming you had a list of items on Sheet10 starting in cell A1 you could read them from there and then all you need to do is add to the list and it will be in your combobox.

Private Sub UserForm_Activate()
    Sheets("Sheet10").Select
    Cells(1, 1).Select
    Do Until ActiveCell = ""
        With ComboBox1
            .AddItem ActiveCell
        End With
        ActiveCell.Offset(1, 0).Select
    Loop
End Sub
0
 
LVL 13

Expert Comment

by:WJReid
ID: 18782808
Hi,
ListBoxes and ComboBoxes do not like working with dynamic ranges, so one way around it is to put a formula in a cell, say Sheet1 cell IV1
="AQ1:AQ" & Counta(AQ1:AQ200)
Then name this range say Rnge
Insert|Name|Define, then type Rnge as the name
In the Refers to box type =Indirect(Sheet1!$IV$1)
Now set the Row Source for your ListBox to =Rnge

Bill
0
 
LVL 18

Expert Comment

by:p912s
ID: 18783118
Thanks for the grade!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now