Solved

Excel comboboxes and their sources using vba

Posted on 2007-03-23
3
173 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot 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…

770 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