+ Reply to Thread
Results 1 to 10 of 10

Macro to copy and paste without overwriting existing data

  1. #1
    Registered User
    Join Date
    01-15-2016
    Location
    Jupiter, FL
    MS-Off Ver
    2010
    Posts
    5

    Macro to copy and paste without overwriting existing data

    What I have is a report that we update daily. New lines are inserted in the existing worksheet daily. Column H is the desired due date and column J is expected completion date (which is manually updated by project managers). What I would like to do is have a macro that will copy column H and paste to Column J (making the completion date equal to desired due date, but not overwrite cells in Column J that already have expected completion date.

    sample
    H J
    1/01/16 1/15/16
    1/01/16
    1/01/16 1/16/16
    1/01/16 1/08/16
    1/01/16

    desired output
    H J
    1/01/16 1/15/16
    1/01/16 1/01/16
    1/01/16 1/16/16
    1/01/16 1/08/16
    1/01/16 1/01/16

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to copy and paste without overwriting existing data

    Hi jmack
    Suppose your dates are in row 1
    try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to copy and paste without overwriting existing data

    Try this:-
    Please Login or Register  to view this content.
    Regards Mick

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to copy and paste without overwriting existing data

    Thanks Mr. Mick for this nice code
    But your results are fixed at all the blank cells in column J .. it is supoosed to be equal to the value in column H in the same row
    I think it should be like that
    Please Login or Register  to view this content.
    Last edited by YasserKhalil; 01-15-2016 at 10:53 AM.

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to copy and paste without overwriting existing data

    It idea looked good on Paper , pity I overlooked the results !!!!!

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to copy and paste without overwriting existing data

    Quote Originally Posted by MickG View Post
    It idea looked good on Paper , pity I overlooked the results !!!!!
    Yes you are right. It looks very good and I'm surprised why it didn't bring correct results ..?

  7. #7
    Registered User
    Join Date
    01-15-2016
    Location
    Jupiter, FL
    MS-Off Ver
    2010
    Posts
    5

    Re: Macro to copy and paste without overwriting existing data

    Thanks to everyone for the quick replies. The code by YasserKhalil worked perfectly, thanks!

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to copy and paste without overwriting existing data

    You're welcome
    Thanks for the feedback
    And many thanks for Mick for his nice and great code that I make use of it to achieve the task
    Regards

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro to copy and paste without overwriting existing data

    This is my try to do the task without looping
    Please Login or Register  to view this content.

  10. #10
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to copy and paste without overwriting existing data

    YasserKhalil , Nice code !!!!

    Slight addition, Perhaps:-
    Please Login or Register  to view this content.
    Last edited by MickG; 01-18-2016 at 07:56 AM.

+ 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. Data Validation - Avoid overwriting due to copy/paste
    By amitgaja007 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2015, 01:29 AM
  2. Copy data without overwriting existing data
    By pcdots in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2014, 01:01 PM
  3. Replies: 11
    Last Post: 11-04-2013, 04:32 PM
  4. Replies: 3
    Last Post: 10-14-2013, 03:06 PM
  5. Stop overwriting cells - Copy and paste macro
    By juhaszp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2013, 05:37 PM
  6. Macro to copy and paste data into database
    By kayoke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 05:00 AM
  7. Replies: 2
    Last Post: 06-11-2012, 05:36 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