+ Reply to Thread
Results 1 to 6 of 6

Copy to next available row leaves blank row

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Question Copy to next available row leaves blank row

    Hello,

    I have set up a macro to filter entire row to another sheet if certain criterias are met.
    This works like a charm, BUT:

    When it pastes the row to the destination sheet, it always leaves a blank row between it and the previous (in destination sheet).
    Is this possible to fix somehow?

    Example:
    In destination sheet the next avilable row is 11
    However, the content is added on row 12, leaving row 11 blank.

    Here is the code:
    Please Login or Register  to view this content.

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

    Re: Copy to next available row leaves blank row

    It is because you have data which appears to be blank to your eyes, but may not be blank to VBA.

    Please Login or Register  to view this content.
    Pastes in to next empty row

  3. #3
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Copy to next available row leaves blank row

    Ok.

    Is it then possible to add something like:
    - Delete the row above the one that was pasted to?

    Example:
    If it paste it to row 11 (leaving 10 blank for my eyes), delete row 10.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Copy to next available row leaves blank row

    Have you checked that A11 on the Norway sheet is in fact blank? It may contain a space or some other non visible character.

    If not upload the workbook so that we can see the problem in context.

    A few observations.

    You don't Dim LR1 which suggests you don't have "Option Explicit" as the first line and in the VB Tools Options editor tab you don't have 'Require Variable Declaration' ticked, which is always good practice,

    Why do you have two filter criteria both for Norway? Won't one do?

    Don't forget that if you use Advanced Filter that you can avoid having to do an AutoFilter and then a Copy Paste. Personally I generally prefer the advanced filiter since the code is shorter and it just seems more elegant.

    If you modify the
    .SpecialCells(xlCellTypeVisible).EntireRow.Copy
    to
    .SpecialCells(xlCellTypeVisible).Offset(1,0).EntireRow.Copy

    you will avoid having the need to delete the row of column labels.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    06-26-2014
    Location
    Norway
    MS-Off Ver
    10
    Posts
    43

    Re: Copy to next available row leaves blank row

    Thank you very much Richard!

    You solved the initial question! It now works like a charm

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Copy to next available row leaves blank row

    Glad to have helped and thanks for the rep.

+ 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. Tree View of PivotTable hiding (blank) leaves
    By dbooksta in forum Excel General
    Replies: 8
    Last Post: 01-26-2018, 03:12 PM
  2. [SOLVED] Need a formula which leaves cell blank when no information entered
    By fben015 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2013, 06:00 PM
  3. [SOLVED] If statement that copies text from a separate worksheet, or if blank, leaves cell blank.
    By barleycorn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2012, 12:30 PM
  4. Replies: 4
    Last Post: 07-17-2006, 03:55 PM
  5. [SOLVED] Hiding Rows Leaves Labels Blank
    By Laura in forum Excel General
    Replies: 3
    Last Post: 03-24-2006, 09:15 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