Solved

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

Posted on 2001-09-17
2
195 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

867 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

23 Experts available now in Live!

Get 1:1 Help Now