Results 1 to 4 of 4

How do I split up data and copy it to a new workbook?

Threaded View

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    49

    How do I split up data and copy it to a new workbook?

    I have a table with the Columns: Date, Col1, Col2, Col3.

    I want to copy all the rows with the same date into a new workbook. The date is in order. I have a code written that works. However, it takes forever to run, because it is looping through each row. I have A LOT of rows.

    Is there no way to just select and copy a chunk and then paste it all just once? I think it takes long because it is pasting each individual row separately.

    Thanks.

    Here is my code:

    
    Sub CopyToWorkbook()
    
    Dim NewBook As Workbook
    Dim OldBook As Workbook
    
    Dim Import As Worksheet
    Dim Raw As Worksheet
    
    Dim t As Long
    
    Set OldBook = Workbooks("OldBook.xlsm")
    Set Import = OldBook.Worksheets("import.xlsm")
    
    
    Set NewBook = Workbooks.Add
    
    NewBook.Sheets.Add.Name = "Raw"
    
    Set Raw = NewBook.Worksheets("raw")
    
        
    Do While Import.Cells(t, 2) = "8/19/2014"
        
        Import.Cells(t, 1).EntireRow.Copy Destination:=Raw.Cells(t, 1)
        
        t = t + 1
        
    Loop
    
    End Sub
    Last edited by bananajelly; 08-21-2014 at 03:39 PM. Reason: Clarification.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Split workbook into multiple workbooks based on data
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2014, 12:26 AM
  2. Split and Extract data from master workbook into several other workbooks
    By kezzyk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-29-2013, 01:00 AM
  3. [SOLVED] Split data into different worksheets in a new workbook.
    By fdotlix in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-31-2012, 07:01 PM
  4. [SOLVED] Split Macro modification to Split into new Workbooks instead of sheets within one workbook
    By DLSmith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2012, 08:11 PM
  5. Replies: 1
    Last Post: 04-01-2006, 03:50 PM

Tags for this Thread

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