+ Reply to Thread
Results 1 to 11 of 11

Problems with reading stuff from closed files

Hybrid View

bluesdata How to retrieve data from... 12-18-2007, 05:19 AM
antoka05 Try to see this URL:... 12-18-2007, 05:43 AM
bluesdata2 Problems with reading stuff... 12-19-2007, 02:58 PM
bluesdata3 Problems with reading stuff... 12-20-2007, 01:39 AM
Leith Ross Hello bluesdata3, It would... 12-20-2007, 02:38 AM
jindon Let's see if this is any... 12-20-2007, 03:00 AM
bluesdata4 one more thing, is it... 12-20-2007, 03:49 AM
jindon How about Sub... 12-20-2007, 03:52 AM
  1. #1
    Registered User
    Join Date
    12-17-2007
    Posts
    2

    How to retrieve data from other excel files?

    Hi,
    I would like to create a single excel file, which is composed by fragments of different (closed) excel fies (it should take some data from the files).
    Is that possible?
    Thanks

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Try to see this URL:
    http://www.rondebruin.nl/copy7.htm

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    12-19-2007
    Posts
    1

    Problems with reading stuff from closed files

    Hello,

    Yesterday, I asked how to read stuff from closed files.
    Someone kindly suggested the following link:

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

    I tried that and it worked, the problem is that it's too slow.
    In the main sub, it uses DoEvents (which yields the processor), which is what I believe that causes it to be slow.
    1) Is it necessary to use the wait operation?
    2) Do you know faster / other ways to read data from (many) other xls files?

    Thanks a lot!

  4. #4
    Registered User
    Join Date
    12-20-2007
    Posts
    1

    Problems with reading stuff from closed files

    Hello,

    Yesterday, I asked how to read stuff from closed files.
    Someone kindly suggested the following link:

    http://www.rondebruin.nl/copy7.htm
    I tried that and it worked, the problem is that it's too slow.
    In the main sub, it uses DoEvents (which yields the processor), which is what I believe that causes it to be slow.
    1) Is it necessary to use the wait operation?
    2) Do you know faster / other ways to read data from (many) other xls files?

    Thanks a lot!

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello bluesdata3,

    It would help to know how slow is slow? There are other methods of data retrieval from a closed workbook, but selecting the best method depends on several factors. It would be best for you to post your workbook so a workable solution can be suggested.

    Sincerely,
    Leith Ross

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Let's see if this is any faster
    Sub GetRange(FilePath As String, FileName As String, SheetName As String, _
                 SourceRange As String, DestRange As Range)
    
        Dim Start
        Application.Goto DestRange
        Set DestRange = DestRange.Resize(Range(SourceRange).Rows.Count, _
                                         Range(SourceRange).Columns.Count)
        With DestRnage
            .Formula = "='" & FilePath & "/[" & FileName & "]" & SheetName _
                            & "'!" & Range(SourceRange).Cells(1).Address(0,0)
            .Value = .Value
        End With
            Start = Timer
    End Sub

  7. #7
    Registered User
    Join Date
    12-20-2007
    Posts
    1
    one more thing, is it possible just to put the 'wait' section in a comment?
    thanks

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    How about
    Sub GetRange(FilePath As String, FileName As String, SheetName As String, _
                 SourceRange As String, DestRange As Range)
    
        Dim Start, i As Long
        Application.Goto DestRange
        Set DestRange = DestRange.Resize(Range(SourceRange).Rows.Count, _
                                         Range(SourceRange).Columns.Count)
        With DestRnage.Rows(1)
            For i = 1 To .Columns.Count
                .Cells(1,i).Formula = _
                       "='" & FilePath & "/[" & FileName & "]" & SheetName _
                            & "'!" & Range(SourceRange).Cells(1,i).Address(0,0)
            Next
            .AutoFill .Resize(DestRange.Rows.Count)
            .Resize(DestRange.Rows.Count).Value = Resize(DestRange.Rows.Count).Value
        End With
            Start = Timer
    End Sub
    Why ?
    What you are doing is just reading the block of range into the same size of the range.
    No need to use Array Formula. and Do Events

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    You code is using FormulaArray, which doesn't need to be an array formula.
    Array formula needs more time to calculate.

    Show me the code that you are calling this sub routine.

+ 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