Results 1 to 4 of 4
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329

    grab data from excel worlsheet


    i Guy's a little stuck with the the correct method for this one, i am trying read a specific cell from an excel file from Access vba

    This is what i have got so far with a msg box to return a result, msg box comes up but no data.

    Once I get the method correct am going to play about with viewing a range of cells from an recordset.count (Not got this far yet just trying return data first)

    Code:
    Dim xlROW As LongDim myRow As Integer
    
    
    Dim strFilePath As String
    strFilePath = "C:\Users\myName\Desktop\Weekly Bookings\11-11-20 WEB UPDATE.xlsx"
    
    
    Dim xl As Excel.Application
    Dim xlsht As Excel.Worksheet
    Dim xlWrkBk As Excel.Workbook
    Dim myResult As String
    Set xl = CreateObject("Excel.Application")
    Set xlWrkBk = GetObject(strFilePath)
    Set xlsht = xlWrkBk.Worksheets(1)
    myResult = xlsht.Cells(3, 3).Value
    MsgBox (myResult)
    Set xl = Nothing
    Set xlWrkBk = Nothing

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    and you definitely have a value in cell C3?

    have you tried stepping through the code and on the

    Set xlsht = xlWrkBk.Worksheets(1)

    line type into the immediate window

    ?xlWrkBk.Worksheets(1).name

    to confirm you are on the right worksheet?

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    If you just want data from a single cell you could likely do it with one line of code. If not, this site is where I'd recommend that you look for help
    http://www.accessmvp.com/KDSnell/EXC...ort.htm#ImpSQL
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,329
    Thank you guy's, i will look into it further, much appreciated

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

Similar Threads

  1. Grab letters after a particular string
    By Rustin788 in forum Queries
    Replies: 3
    Last Post: 08-02-2017, 11:55 AM
  2. Replies: 3
    Last Post: 11-13-2014, 12:37 PM
  3. Replies: 2
    Last Post: 01-10-2012, 06:41 PM
  4. Grab first characters from field
    By sau3-access in forum Access
    Replies: 1
    Last Post: 10-04-2011, 10:40 AM
  5. grab partial data from one cell
    By andiwir in forum Queries
    Replies: 4
    Last Post: 08-10-2011, 08:55 PM

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