+ Reply to Thread
Results 1 to 12 of 12

VBA to copy first to last row stopping at first balnk row...

  1. #1
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    VBA to copy first to last row stopping at first balnk row...

    Hi

    I am using the following code to select and copy the first to last row in multiple sheets to a "combined" sheet. I am not sure where I am going wrong but the macro doesn't select all rows up to the last row, it stops at the first blank row.

    Please Login or Register  to view this content.
    Please help

    Thanks
    Louis

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    use this line

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    Re: VBA to copy first to last row stopping at first balnk row...

    Hi AB33

    It is still not selecting all the lines, for some reason it is stopping at line 28, I have various number of lines per sheet, ranging from 300 to 1250.

    Column A is the main column where all data originate per line but there is a couple of blank rows in between the first and the last row.

    Thanks for the help.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    If this line does not work, I need to see your sample

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    Re: VBA to copy first to last row stopping at first balnk row...

    Hi AB33

    Please see attached

    Template 5.xlsm

    Thanks

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    Thank you!
    So you are trying to copy all sheets except the first 2, from columns A-Q in to combined sheet. Am I right?

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    You need to add headers in row 1 on combined sheet.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    Re: VBA to copy first to last row stopping at first balnk row...

    Hi AB33

    I get a Run time error 91: Object variable or With block variable not set.

    Regards
    Louis

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    Not my code. You have two codes on the module. You might have attached your button to your old code. If it is my code, in which line the code does error? You need to run my code from the module as I have not attached it to any button.

  10. #10
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    Re: VBA to copy first to last row stopping at first balnk row...

    Hi AB33

    I did run it from the module

    Please see below for the line:

    Please Login or Register  to view this content.
    Thanks

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to copy first to last row stopping at first balnk row...

    You need to add a header in row 1 as I did my self on combined sheet. That line of code will not work with blank sheet.
    Since the code first clears existing data from row 2, you need to have a data in row 1.

  12. #12
    Registered User
    Join Date
    12-04-2014
    Location
    South Africa, Gauteng
    MS-Off Ver
    2010
    Posts
    22

    Re: VBA to copy first to last row stopping at first balnk row...

    Thanks for the help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] removing the balnk data in the pivot
    By kachuen2006 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 07-11-2013, 06:29 AM
  2. Copy and Paste Loop but keeps stopping
    By kksf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2013, 04:03 AM
  3. End Macro when balnk cell
    By paconovellino in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2013, 04:06 PM
  4. Issue with balnk cells.....
    By garethjohn in forum Excel General
    Replies: 7
    Last Post: 08-18-2011, 05:35 AM
  5. Imported data with balnk rows
    By gcastilleja in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-16-2010, 08:10 PM

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