+ Reply to Thread
Results 1 to 4 of 4

Get values from a closed workbook

  1. #1
    Registered User
    Join Date
    06-02-2006
    Posts
    39

    Get values from a closed workbook

    I got this code from the website:

    Sub test()
    GetValuesFromAClosedWorkbook "C:", "Book1.xls", "Sheet1", "A1:A30"
    End Sub

    Sub GetValuesFromAClosedWorkbook(fPath As String, fName As String, _ sName, cellRange As String)

    With ActiveSheet.Range(cellRange)
    .FormulaArray = "='" & fPath & "\[" & fName & "]" & sName & "'!" & _ cellRange
    .Value = .Value
    End With
    End Sub

    Can someone explain how it works? It looks like the path/file name is already configured, so why (when I run the code) does an "Update Records" dialog box pop up?

  2. #2
    halim
    Guest

    Re: Get values from a closed workbook

    Dear KEV06,

    Let me try to explain you that :
    (the explanation is after " '-->" and " _" mark & ended by dot.)

    Sub test()
    GetValuesFromAClosedWorkbook "C:", "Book1.xls", "Sheet1", "A1:A30"
    ' --> call _
    GetValuesFromAClosedWorkbook sub event to raised up the event.
    End Sub

    Sub GetValuesFromAClosedWorkbook(fPath As String, fName As String, _
    sName, cellRange As String)

    With ActiveSheet.Range(cellRange)
    .FormulaArray = "='" & fPath & "\[" & fName & "]" & sName &
    "'!" & cellRange ' --> excel _
    standard way of linked cells to another Workbook that
    currently not open.
    .Value = .Value ' --> return formularray to value.
    End With
    End Sub


    Or you can contact me directly to [email protected]
    thats all,

    halim



    kev_06 menuliskan:
    > I got this code from the website:
    >
    > Sub test()
    > GetValuesFromAClosedWorkbook "C:", "Book1.xls", "Sheet1", "A1:A30"
    > End Sub
    >
    > Sub GetValuesFromAClosedWorkbook(fPath As String, fName As String, _
    > sName, cellRange As String)
    >
    > With ActiveSheet.Range(cellRange)
    > .FormulaArray = "='" & fPath & "\[" & fName & "]" & sName &
    > "'!" & _ cellRange
    > .Value = .Value
    > End With
    > End Sub
    >
    > Can someone explain how it works? It looks like the path/file name is
    > already configured, so why (when I run the code) does an "Update
    > Records" dialog box pop up?
    >
    >
    > --
    > kev_06
    > ------------------------------------------------------------------------
    > kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
    > View this thread: http://www.excelforum.com/showthread...hreadid=559565



  3. #3
    Ron de Bruin
    Guest

    Re: Get values from a closed workbook

    See
    http://www.rondebruin.nl/copy7.htm



    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "kev_06" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I got this code from the website:
    >
    > Sub test()
    > GetValuesFromAClosedWorkbook "C:", "Book1.xls", "Sheet1", "A1:A30"
    > End Sub
    >
    > Sub GetValuesFromAClosedWorkbook(fPath As String, fName As String, _
    > sName, cellRange As String)
    >
    > With ActiveSheet.Range(cellRange)
    > FormulaArray = "='" & fPath & "\[" & fName & "]" & sName &
    > "'!" & _ cellRange
    > Value = .Value
    > End With
    > End Sub
    >
    > Can someone explain how it works? It looks like the path/file name is
    > already configured, so why (when I run the code) does an "Update
    > Records" dialog box pop up?
    >
    >
    > --
    > kev_06
    > ------------------------------------------------------------------------
    > kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
    > View this thread: http://www.excelforum.com/showthread...hreadid=559565
    >




  4. #4
    Registered User
    Join Date
    04-19-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Get values from a closed workbook

    I have been successfully using this method for a few months but...
    1) when I first started using it a strange problem occurred but it went away
    2) it has just come back

    The problem is that when the array formula is inserted sometimes it adds an extra backslash after the path so the formula breaks.
    If I go and open the target file and close it again the formula works.

    For example: ='C:\WeekRep\\[my_report.xlsm]Risk Log'!E10:AA10 instead of:
    ='C:\WeekRep\[my_report.xlsm.xlsm]Risk Log'!E10:AA10

    Anyone come across this before:
    Last edited by Nigelba; 04-23-2013 at 04:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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