Solved

Excel comboboxes and their sources using vba

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

821 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