Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel comboboxes and their sources using vba

Posted on 2007-03-23
3
Medium Priority
?
180 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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