I assume that you would implement these list boxes in a user form. In that
case you can use, the Jet OLEDB Provider For Microsoft Excel Databases, to
query an XLS file. Below is the code snippet to use.

The code demonstrates how to use Jet OLEDB Provider For Microsoft Excel
Databases. You need to add a reference to your VBA project for The Microsoft
Activex Data Objects Library msado20.tlb or an equivalent.

Sub Sample()
    Dim Con As New ADODB.Connection
    Dim Rst As Recordset
    Dim Rng As Range

    'Set con = CreateObject("ADODB.Connection")
    StrCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
             "Data Source=" & ActiveWorkbook.FullName & ";" & _
             "Extended Properties=Excel 8.0;"
    Con.Connectionstring = StrCon
    Con.Open

    Set Rst = Con.Execute("SELECT *, ([Emp].SAL * 0.2) FROM [sheet1$A1:H15]
EMP, [sheet2$A1:C5] DEPT " & _
                          "WHERE [EMP].DEPTNO = [DEPT].DEPTNO")

    Set Rng = Sheets(3).Range("A1")

    While Rst.EOF = False
        Rng.Value = Rst.GetString(NumRows:=1, RowDelimeter:="", _
                                  ColumnDelimeter:=",", NullExpr:="")
        'Rst.MoveNext
        Set Rng = Rng.Offset(1, 0)
    Wend
End Sub

Take a look at the following link to learn more....

http://support.microsoft.com/kb/257819/EN-US/

http://www.codemaker.co.uk/it/tips/ado_conn.htm#OLEDBProviderForExcel

Regards,

Ajit

On Wed, Sep 24, 2008 at 4:47 AM, Laoballer <[EMAIL PROTECTED]> wrote:

>
> I have a set of data that looks like this
>
> STATE      CITY
> OR           Portland
> OR           Beaverton
> WA          Seattle
> WA          Olympia
> WA          Spokane
> CA           Los Angeles
> CA           San Diego
> CA           San Jose
>
> What I would like to be able to do is have 3 list boxes, the first one
> would contain the State abbreviation, OR,WA,CA
> which I can multiselect and then the 2nd listbox would populate with
> all the city's that belong to the states chosen.  These two would be
> in a where clause of an sql statement that I would query a database to
> return data that populates the 3rd listbox.  How would I go about
> doing this?
>
> Thanks
>
> >
>


-- 
Thank You,

Ajit Navre

--~--~---------~--~----~------------~-------~--~----~
Visit the blog to download Excel tutorials at 
http://www.excel-macros.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/excel-macros?hl=en

Visit & Join Our Orkut Community at 
http://www.orkut.com/Community.aspx?cmm=22913620

Visit the blog to download Excel tutorials at 
http://www.excel-macros.blogspot.com

To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com

To see the Daily Excel Tips, Go to:
http://exceldailytip.blogspot.com
-~----------~----~----~----~------~----~------~--~---

Reply via email to