Results 1 to 3 of 3

Thread: VBA to Copy Rows Until Blank Row and Paste Data on First Blank Row

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0

    VBA to Copy Rows Until Blank Row and Paste Data on First Blank Row

    I am trying to create VBA for a macro in which my excel spreadsheet will always have data in Columns A-W but will have an undetermined row count. I need the macro to copy the rows with data and then paste those rows into the first blank row. The first row is always my header row. For example, I have data in rows 2-8 so I would want the macro to copy rows 2-8 and paste the data starting on row 9. The next time I use the macro, I may only have data in rows 2-4 so I need it to copy those rows and paste the data beginning on row 5. Can someone help?

  2. #2
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    Try this:

    Code:
    Option Explicit
    Sub Mel()
        Dim lr As Long
        lr = Range("A" & Rows.Count).End(xlUp).Row
        
        Application.ScreenUpdating = False
        Range("A2:W" & lr).Copy Range("A" & lr + 1)
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
        MsgBox ("task complete")
    
    End Sub

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0
    That worked, thank you very much!

Similar Threads

  1. finding first blank row
    By peter renton in forum Excel Help
    Replies: 2
    Last Post: 12-31-2013, 05:34 PM
  2. Replies: 0
    Last Post: 12-24-2013, 01:36 PM
  3. Replies: 2
    Last Post: 02-11-2013, 08:13 PM
  4. Autofill the data based on non blank cell in next row?
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 3
    Last Post: 11-29-2012, 04:16 PM
  5. Replies: 2
    Last Post: 09-24-2012, 11:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •