Solved

Excel comboboxes and their sources using vba

Posted on 2007-03-23
3
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

623 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