+ Reply to Thread
Results 1 to 27 of 27

Copy to first empty line on next Sheet.

  1. #1
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Copy to first empty line on next Sheet.

    Hi, all

    I'm working with a code that will copy contents of a row from one sheet to the last row on the next sheet however, the information on the latter sheet's rows will be removed in a random order. Is there a way to copy the contents to the first empty row, rather than the last row? There will be a lot of information over time removed latter sheet and I'd rather that sheet not have 200+ empty rows over time at the top.

    Here's the code I'm working with:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Copy to first empty line on next Sheet.

    Would it not be better to delete all empty rows in the 2nd sheet first and then put the data from the first sheet at the bottom?
    That would eliminate the empty rows altogether as you mentioned that you don't want them.
    Either way is no problem, just let us know.

    Try this on a copy of your workbook.
    I assume that you want the data of the selected cell(s) copied.
    Change references as required.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 08-06-2022 at 01:21 PM.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by QualitySoup View Post
    ... to copy the contents to the first empty row, rather than the last row ...
    Strange "needs" ... try:
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 08-06-2022 at 03:31 PM.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Copy to first empty line on next Sheet.

    My apologies. I have the nasty habit to go by what people explain without delving into the not working code. After all, the code is not doing what one expects.
    I also noticed that you want a larger range copied/pasted.
    Forget Post #2.
    It can easily be changed to fit your needs but you have a few well respected helpers that have suggestions for you already.

  6. #6
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    This replaces the Rows on receiving sheet from top to bottom. If possible, I need it to find the first empty row on the receiving sheet.

  7. #7
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by mjr veverka View Post
    Strange "needs" ... try:
    Please Login or Register  to view this content.
    This bring a Run-time error '1004': We can't do that to a merged cell.
    Is there a way to Upload the workbook or sheet here to give a better idea?

  8. #8
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Is there a way to Upload the workbook or sheet here to give a better idea?
    Here's the workbook for reference.
    Attached Files Attached Files

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    I tested the macro using some dummy data and it worked properly. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).

  10. #10
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    I tested the macro using some dummy data and it worked properly. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet...
    I've uploaded the workbook above. Do you still need XL2BB?

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Try:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    I'm getting a Run-time Error on this one.
    Run-time error '1004': We can't do that to a merged cell.

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Try the attached file. I had to unmerge the cells in row 1 of each sheet. I have reformatted the range in row 1 as "CenterAcrossSelection". The cells look merged but are actually not merged.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Try the attached file. I had to unmerge the cells in row 1 of each sheet. I have reformatted the range in row 1 as "CenterAcrossSelection". The cells look merged but are actually not merged.
    This is PERFECT! Thank you so much for your help!!

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    You are very welcome.

  16. #16
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    So I found an issue. When Rows 3 and beyond are empty, The information goes to B1 and unformats the row.

  17. #17
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Try:
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Everything works except the Clear Contents. The information for that row stays on the original sheet.

  19. #19
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Ok so, I removed the " ' " from before the " 'Rows(r).ClearContents " and it works perfectly.

  20. #20
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Glad it worked out.

  21. #21
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Glad it worked out.
    Is there a way to implement this on the second sheet as well? I tried putting the code on the second sheet so that it'll copy to the third, but it had the same issue as before; replacing B2.

    The way that it'll hopefully work in the end is that information will start on sheet 1, then when it meets criteria move it to sheet 2, then to sheet 3 when it meets criteria.
    Last edited by QualitySoup; 08-08-2022 at 11:11 PM.

  22. #22
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    I'm not sure what you mean. Do you want to be able to double click on a value in column C in any sheet and copy the data to the next sheet? Please clarify in detail step by step, and attach an updated file to demonstrate what you mean.

  23. #23
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    I'm not sure what you mean. Do you want to be able to double click on a value in column C in any sheet and copy the data to the next sheet? Please clarify in detail step by step, and attach an updated file to demonstrate what you mean.
    Hey disregard what I said (user error lol) This works great!
    Last edited by QualitySoup; 08-09-2022 at 09:04 PM.

  24. #24
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    Glad it worked out.
    Not to revive an old thread but...
    Is there anyway to exclude column A when moving the contents in the below code?

    Please Login or Register  to view this content.
    Thank you in advance!

  25. #25
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    The code currently starts copying at column C so column A is not included.

  26. #26
    Registered User
    Join Date
    08-01-2022
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    14

    Re: Copy to first empty line on next Sheet.

    Quote Originally Posted by Mumps1 View Post
    The code currently starts copying at column C so column A is not included.
    Sorry. What I meant to ask is when the code clears contents at the end, is there a way to not clear contents in column A?

  27. #27
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Copy to first empty line on next Sheet.

    Replace:
    Please Login or Register  to view this content.
    with:
    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)

Similar Threads

  1. VB code to delete empty page's in excel sheet where line is empty
    By davitali in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2018, 04:18 AM
  2. [SOLVED] Empty sheet before updating but leave title line at top and totals line at bottom
    By rmarenyi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-22-2017, 10:42 AM
  3. Trying to copy fixed row of cells, paste to next empty line, and clear fixed line.
    By oh_stanley in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-24-2014, 07:44 PM
  4. Copy the data from 1 sheet in vertical line to another sheet in horizontal line
    By Shermaine2010 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2014, 03:46 AM
  5. [SOLVED] If one cell in line turn empty then entire line turns empty
    By Cristy0505 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-19-2013, 06:02 AM
  6. Macro copy data to next empty line (help please)
    By pepijn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2012, 12:11 PM
  7. [SOLVED] Copy and Paste in the first empty available line.
    By Etienne in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2006, 10:55 AM

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