+ Reply to Thread
Results 1 to 7 of 7

Macro to copy from several cells into another workbook on the next empty row

  1. #1
    Registered User
    Join Date
    02-08-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    15

    Macro to copy from several cells into another workbook on the next empty row

    I am working on a sheet where I need to export cells B7, B9, E9, B13, F18, F20:F22, F24, F30, F32:F34, and H34 into another workbook where the data will be copied into the next empty row (all on one row). I am then linking this function to a "Submit" button.
    I can do most of this my simply recording a macro, but I cannot figure out how to search for an empty row and paste. I am sure there is a way to copy those cells with one command as well, but I have not been able to figure out the syntax, so each copy/paste operation has its own line. The code I have so far is:
    Please Login or Register  to view this content.
    If anyone doesnt mind showing me how to consolidate this code as well as paste to the next open row, I would really appreciate that. Since I want to learn how to do this better I would also appreciate any comments in your code that you would be willing to make so I can follow it easier.
    Thanks!
    Last edited by mjj347; 02-09-2012 at 03:01 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Need a little help with a Macro please

    Welcome to the forum,

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro that copies from several cells into another workbook on the next empty row

    Try this

    Please Login or Register  to view this content.
    Last edited by Bob Phillips; 02-08-2012 at 12:12 PM. Reason: Posted before warning seen

  4. #4
    Registered User
    Join Date
    02-08-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro that copies from several cells into another workbook on the next empty row

    Thank you.
    That code is generating an error that says 'Wrong number of arguments or invalid property assignments" and it looks to be unhappy with this line
    Please Login or Register  to view this content.
    Does TestTargetSheet need to be set as ActiveSheet? I tried to change it but I am still getting that same error.
    Last edited by mjj347; 02-08-2012 at 12:57 PM.

  5. #5
    Registered User
    Join Date
    02-08-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro that copies from several cells into another workbook on the next empty row

    Still no luck. Bump

  6. #6
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro that copies from several cells into another workbook on the next empty row

    Correction

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-08-2012
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Macro that copies from several cells into another workbook on the next empty row

    Thank you very much! That code compiled perfectly.
    If anyone has the same problem and I made some small changes as shown below. First, the fields I needed to extract from changed slightly and I needed operations for transposing a couple of the paste operations to fit them on a single row, and then set all of the operations to paste cell values only. Thanks again Bob Phillips!

    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)

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