Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

856 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