Solved

VBA: How to fill in a comboxbox from excell sheet?

Posted on 2001-09-17
2
194 Views
Last Modified: 2010-05-02
I must do a little program in excell vba but I must fill in a combox from excell sheet with distinct value.  Could you help me.
EX:
LLII
PASE
PASE
QSDF
QSDF
GDQD
wxcv
wxcv
wxcv
wxcv



In my combobox I neeed only LLII,PASE,QSDF,GDQD,wxcv(it s important have just one)?
Thank
0
Comment
Question by:zoltix
2 Comments
 
LVL 15

Accepted Solution

by:
lyonst earned 100 total points
ID: 6487539
One way I found that worked.

Use an Advanced Filter to copy the data to another location and specify Unique Records Only.  Then use that data as the source for you Combobox.

Hope this helps,

Cheers,

T.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6488219
Here's a simple macro:

Sub FillCombo()
Dim sht As Worksheet
Dim lRow As Long
Dim sValue As String

    Set sht = Sheets(2) 'data sheet
    lRow = 1 'startrow
   
    On Error Resume Next
    With ComboBox1
        .Clear
        .Style = fmStyleDropDownList
        Do
            sValue = sht.Cells(lRow, 1).Value
            If Len(sValue) = 0 Then Exit Do 'exit if no value
            .Text = sValue
            If Err.Number <> 0 Then 'not added yet
                .AddItem sValue
            End If
            Err.Clear
            lRow = lRow + 1
        Loop
    End With
End Sub

D'Mzzl!
RoverM
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

747 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

14 Experts available now in Live!

Get 1:1 Help Now