Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 71
How to debug this code 7 61
using web browser with BING 40 119
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 51
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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