Ozgrid Excel Help & Best Practices Forums


XL Templates | XL Add-ins | XL Training | XL Estimating | XL Scheduling | XL Recovery | XL Trading | XL Financial | XL Conversion | XL Charting


+ Reply to Thread
Results 1 to 4 of 4

Thread: Read values from closed workbook?

  1. #1
    Join Date
    30th September 2004
    Posts
    39

    Read values from closed workbook?


    Download Active Data For Excel > > DETAILS > >
    Is it possible for a macro in Workbook_A.xls that is open to read values in Workbook_B.xls that is closed? Both workbooks are stored in the same directory.

    I know it can be doen by linking but this is not what i need.

    If so could someone please show me an example.

  2. #2
    Join Date
    6th September 2004
    Posts
    438
    Code:
    Function GetMax(strMatrix As String) As Long
    
    Dim strResult As String
    Dim strPullText As String
    
    'If we get an error in this function it is because the sheet does not exist
    On Error GoTo NoPage
    
    'Build the string to pull the value from the closed file
    strPullText = "'" & filePATH & "[" & fileMATRIX & "]" & Trim(strMatrix) & "'!R3C2"
    
    'Pull the value from the closed file
    GetMax = Application.ExecuteExcel4Macro(strPullText)
    
    Exit Function
    
    NoPage:
    
    'There was an error so return the fact that the matrix is missing
    GetMax = 0
    Err.Clear
    
    End Function
    You will need to tailor this to suit and adjust the error handling.

    filePATH and fileMATRIX are constants that I have setup in my project.

    TJ
    Oh dear I need a beer
    Online Motorsport Game

  3. #3
    Join Date
    30th September 2004
    Posts
    39
    Thanks - works, but asks to open the workbook on each value. I am looking at loading a array of dimensions 5000x2!

    Any other ideas?

  4. #4
    Join Date
    6th September 2004
    Posts
    438

    Create Excel dashboards quickly with Plug-N-Play reports.
    You could have a look here:

    http://j-walk.com/ss/excel/tips/tip82.htm

    But I would open the workbook, get the array and then close the workbook.

    TJ
    Oh dear I need a beer
    Online Motorsport Game

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Possible Answers

  1. Copy Row Values To Closed Workbook
    By KTM in forum EXCEL HELP
    Replies: 2
    Last Post: October 26th, 2007, 14:23
  2. Get Values From Closed Workbook
    By [the blue fox] in forum EXCEL HELP
    Replies: 2
    Last Post: October 3rd, 2007, 06:25
  3. Replies: 0
    Last Post: June 15th, 2007, 13:28
  4. Read Text From A Closed Workbook
    By jkallis in forum EXCEL HELP
    Replies: 1
    Last Post: March 19th, 2007, 07:39
  5. Values From A Closed Workbook
    By hgus393 in forum EXCEL HELP
    Replies: 2
    Last Post: February 9th, 2007, 17:24

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