Results 1 to 17 of 17

Quickest way to copy data from another workbook

Threaded View

Bip Quickest way to copy data... 12-15-2016, 11:00 PM
Kenneth Hobson Re: Quickest way to copy data... 12-15-2016, 11:26 PM
Bip Re: Quickest way to copy data... 12-16-2016, 12:32 AM
Bip Re: Quickest way to copy data... 12-17-2016, 07:47 PM
mike7952 Re: Quickest way to copy data... 12-17-2016, 09:09 PM
Bip Re: Quickest way to copy data... 12-17-2016, 10:48 PM
mike7952 Re: Quickest way to copy data... 12-18-2016, 12:35 AM
Bip Re: Quickest way to copy data... 12-18-2016, 01:33 AM
mike7952 Re: Quickest way to copy data... 12-18-2016, 09:03 AM
Kenneth Hobson Re: Quickest way to copy data... 12-18-2016, 08:26 PM
Logit Re: Quickest way to copy data... 12-18-2016, 09:33 PM
Kenneth Hobson Re: Quickest way to copy data... 12-18-2016, 09:55 PM
Kenneth Hobson Re: Quickest way to copy data... 12-18-2016, 10:05 PM
Kenneth Hobson Re: Quickest way to copy data... 12-18-2016, 10:18 PM
Bip Re: Quickest way to copy data... 12-19-2016, 12:20 AM
Logit Re: Quickest way to copy data... 12-18-2016, 10:43 PM
Logit Re: Quickest way to copy data... 12-19-2016, 01:28 PM
  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Vanuatu
    MS-Off Ver
    Excel 2007
    Posts
    14

    Quickest way to copy data from another workbook

    Hi, I'm currently using the code below to retrieve rows of data (based on date) from another workbook.
    It works well but after using it for a year the rows of data that it has to search has blown out to 30,000 rows, which has made it very slow.
    I'm not familiar with using arrays or even if it would help here but is there a quicker way to search and copy data from another workbook?

    Sub GetData()
        Dim FileName As String
        Dim DestWB As Workbook
        Dim lastrow As Long
        Dim strdate As String
        Dim DCell As Range
        
        'Get Date to search for
        strdate = ThisWorkbook.Sheets("Variables").Range("A4").Value
        strdate = Format(strdate, "Short Date")
        
        'Get Database Location
        FileName = ThisWorkbook.Sheets("Variables").Range("A8").Value
        
        'Open Database
        Set DestWB = Workbooks.Open(FileName, ReadOnly:=True, notify:=False)
        
        'Copy Data
        ThisWorkbook.Worksheets("List").Rows("2:100000").ClearContents
        lastrow = DestWB.Worksheets("Window1").Cells(Rows.Count, "D").End(xlUp).Row
        For Each DCell In DestWB.Worksheets("Window1").Range("D2:D" & lastrow)
            If CDate(DCell.Value) = strdate Then
                DCell.EntireRow.Copy _
                Destination:=ThisWorkbook.Worksheets("List").Cells(Rows.Count, "A").End(xlUp)(2)
            End If
        Next DCell
        
        'Close Database
        DestWB.Close SaveChanges:=False
        Set DestWB = Nothing
        
    End Sub
    Thanks
    Pete
    Last edited by Bip; 12-16-2016 at 08:51 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Which is the quickest way to loop through large data sets
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-03-2013, 10:38 AM
  2. quickest method for dynamic link to closed workbook
    By bangelta in forum Excel General
    Replies: 0
    Last Post: 10-25-2012, 02:53 PM
  3. [SOLVED] The quickest way to copy formula
    By TomDoubleYou in forum Excel General
    Replies: 7
    Last Post: 07-05-2012, 10:43 AM
  4. Quickest way to summarize random data
    By deucesh75 in forum Excel General
    Replies: 1
    Last Post: 02-06-2010, 01:42 AM
  5. quickest way to copy information to several cells in a very large
    By mja in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2006, 02:30 PM
  6. Replies: 1
    Last Post: 04-01-2006, 03:50 PM
  7. [SOLVED] Quickest way to copy then Paste Special-Values in place?
    By Hash@example.org in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-18-2005, 10:06 AM

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