Results 1 to 2 of 2
  1. #1
    chaddresnick is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Dec 2014
    Location
    Dayton, Ohio
    Posts
    30

    Access & Excel


    Can an Excel spreadsheet reference an Access Table for it's data? Sort of like a vlookup, but instead of referencing another spreadsheet, I'd like to pull data in from a database.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    yes, but its better to do it the other way, read Excel from access...but
    in excel code you must establish an ADO connection to get to the recordsets:

    Code:
    Public Sub CopyRST()
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim DB
    Dim vProvid
    
    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset
     
     uid = "HomerJSimpson"
     pwd = ""
     DB = "\\myserver\production\Generic104J.mdb"
     vProvid = "Microsoft.Jet.OLEDB.4.0"     '  "SQLOLEDB"
     
      
    With con
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Properties("User ID").Value = uid
        .Properties("Password").Value = pwd
        
        .Open "Data Source=" & DB 
    End With
     
    Set rs = con.Execute("qsNames_simps")
    ActiveWorkbook.Worksheets("Sheet1").Range("A1").CopyFromRecordset rs
    
    rs.Close
    con.Close
    
    set rs = nothing
    set con = nothing
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import access query data into excel file, using excel vba
    By exceljockey in forum Import/Export Data
    Replies: 3
    Last Post: 11-15-2013, 02:36 PM
  2. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  3. Replies: 10
    Last Post: 12-28-2012, 02:06 PM
  4. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  5. Replies: 1
    Last Post: 08-31-2009, 10:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums