+ Reply to Thread
Results 1 to 6 of 6

Copy range from one sheet and paste in another sheet on the next visible row after header

  1. #1
    Registered User
    Join Date
    05-20-2013
    Location
    Rotterdam, Holland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Copy range from one sheet and paste in another sheet on the next visible row after header

    Good day, hope someone can help me with a challenge I'm facing. I have recently started on VBA and have come across the following problem:

    The VBA code to copy non-hidden range data from one worksheet, and paste to another worksheet is generally working. But the problem I have come across is that the destination sheet
    has a header row and below that nothing but hidden rows. I would like the destination row to paste to to be the first row after the header row, which is basically the first visible row after all the hidden rows. The last row function will get me to the header row, but Lr + 1 is getting Excel/VBA to paste to the next HIDDEN row.

    So far, the code I have is only working when I unhide the rows in the destination sheet first.

    Can Excel/VBA paste to the next visible row??

    Hope to get your solution, if any.

    Best regards, MaQian.

  2. #2
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Copy range from one sheet and paste in another sheet on the next visible row after hea

    This is assuming the first row is 1 and you're in column A. It will place the active cell below all of the hidden rows. You can then paste after that.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-20-2013
    Location
    Rotterdam, Holland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy range from one sheet and paste in another sheet on the next visible row after hea

    Hi Majosum, thanks for your response. Unf I didn't get it working yet, I must be doing something wrong.

    With the current code it copies the named range data from sheet DailyEnq and pastes it at sheet DailyEmail at Cell H5. Row 4 is where my visible header data is, and below that are quite a lot of hidden rows. Still left with the question on how to get the code to paste to next visible row (in H column), below the visible header row (row 4)?

    For ease of reference I copied the code below. Any suggestions? Much appreciated..

    Please Login or Register  to view this content.
    Last edited by MaQian; 05-22-2013 at 08:46 AM.

  4. #4
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Copy range from one sheet and paste in another sheet on the next visible row after hea

    If you want it in the 5th column instead of column H, set the destination range to be E4 instead of H4.

  5. #5
    Registered User
    Join Date
    05-15-2013
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: Copy range from one sheet and paste in another sheet on the next visible row after hea

    The reason that it still pastes in H4 is because after you do the loop to find the next hidden cell, you never stored that as DestRange

    replace this
    Please Login or Register  to view this content.
    with this
    Please Login or Register  to view this content.
    Last edited by krabine; 05-22-2013 at 09:29 AM.

  6. #6
    Registered User
    Join Date
    05-20-2013
    Location
    Rotterdam, Holland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy range from one sheet and paste in another sheet on the next visible row after hea

    Thanks guys, great help to finally get it working in the end. Storing the DestRange did the trick, although had a tweak a bit to make sure that Active cell had the right starting point in the right worksheet before going through the loop.

    For completeness, final code below. Thanks again.



    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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