+ Reply to Thread
Results 1 to 4 of 4

Excel vba sql select

  1. #1
    Registered User
    Join Date
    08-14-2014
    Location
    HK
    MS-Off Ver
    2010
    Posts
    6

    Excel vba sql select

    Below is my worksheet called 'List'

    name tel address
    ----- --- --------
    Rick 1325689 Flat A
    Hanry 7885654 Room 7
    Rockman 7775432 House 200

    ===================================
    Below is my excel vba code

    ----------------------------------------------

    strQuery = "SELECT * FROM[List$]"
    Set rs = cn.Execute(strQuery)


    strStartlocation = "A1"

    Dim lngColCounter As Long
    For lngColCounter = 0 To rs.Fields.Count - 1
    Range(strStartlocation).Offset(0, lngColCounter) = rs.Fields(lngColCounter).Name
    Next lngColCounter

    ActiveSheet.Range(strStartlocation).Offset(1, 0).CopyFromRecordset rs

    ---------------------------------------------------

    I can success to show all table information
    I want to know how to select and display specific data
    For example, How to display "7775432"

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Excel vba sql select

    SELECT * FROM[List$] WHERE tel =7775432

  3. #3
    Registered User
    Join Date
    08-14-2014
    Location
    HK
    MS-Off Ver
    2010
    Posts
    6

    Re: Excel vba sql select

    Do I need to set any else tone named the column?

  4. #4
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: Excel vba sql select

    about SQL statements you can read here: http://www.baldyweb.com/BuildSQL.htm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Newbie: Auto Select/un-Select an Range of Slicer Items
    By luckyali in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2014, 09:52 AM
  2. [SOLVED] Modify existing code to select file instead of select folder
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2014, 09:41 AM
  3. Code to prevent user to Select COLUMNS but allow to select ROWS
    By tengrosita in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2011, 03:46 AM
  4. How to Use CELLS,RANGE,SELECT,SELECTION & OTHER BASIC EXCEL OBJECTS IN EXCEL VBA
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2008, 12:07 PM
  5. [SOLVED] In Excel 2000, How do you select the whole of a worksheet (Select.
    By Rascal in forum Excel General
    Replies: 1
    Last Post: 03-04-2005, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1