+ Reply to Thread
Results 1 to 6 of 6

Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

  1. #1
    Registered User
    Join Date
    05-18-2018
    Location
    Boston
    MS-Off Ver
    2010
    Posts
    3

    Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

    Hi All - I am working on a large spreadsheet where I am copying, pasting and rearranging data by column on a weekly basis. I am trying to create a macro the does this automatically for me but I need it to NOT overwrite previously pulled over data from prior weeks as it will be edited and I do not want to have to redo the work. I would like the code to recognize the last copied cells from the previous week and only copy over new data. Can someone assist me in completing this code to do so? This is what I have as of right now:

    Please Login or Register  to view this content.

    Any help or guidance is greatly appreciated!! Thank you!!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

    There is not enough information in your description or code to answer this. It is going to depend on how your data is organized, and how you can tell which data is "previously pulled over data from prior weeks".

    Please attach your file. The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-18-2018
    Location
    Boston
    MS-Off Ver
    2010
    Posts
    3

    Re: Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

    Thank you 6StringJazzer! I appreciate your time. I uploaded an edited version of the file to give a general idea of what I am working with. In this example, I have rows 2-14 copied over from sheet1 to sheet2 and have made some edits. I now need row 15-20 to copy over without overwriting the information in rows 2-14.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    A demonstration as a starter :

    PHP Code: 
    Sub Demo1()
        
    Dim R&
            
    Sheet2.UsedRange.Rows.Count
        With Sheet1
    .UsedRange.Rows
            
    If < .Count Then .Item(":" & .Count).Copy Sheet2.Cells(16)
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Registered User
    Join Date
    05-18-2018
    Location
    Boston
    MS-Off Ver
    2010
    Posts
    3

    Re: Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

    Thanks for assisting, Marc L! Unfortunately, this code doesn't prevent any edited data from sheet2 from being changed back to the source data on sheet1 when running the Macro. Any suggestions?\


    Thank you!

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Using VBA Macros to Copy and Paste Without Overwriting Previously Copied Data

    First, there is no code in what you attached, notwithstanding what you posted to start the thread.

    The thing that is still missing from your description is how to know what is new vs. what has already been copied over. This can be tricky because you are editing data after it's been copied to the other sheet. There has to be some data that uniquely identifies each record that will never change.

    If we are guaranteed that the "Full Name" will never change after it's copied, and all full names are unique, then the attached code will copy over only the new names.

    BTW "Total # of People in Household" is not available in sheet 1, assuming you add that later.
    Attached Files Attached Files

+ 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. Timer to automatically copy only if the previously copied one pasted
    By catchnanan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2017, 12:56 PM
  2. Macro to copy and paste without overwriting existing data
    By jmack36 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-18-2016, 07:49 AM
  3. 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
  4. How to copy and paste data into middle of other cell without overwriting?
    By papisox in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-24-2014, 02:07 PM
  5. Replies: 1
    Last Post: 09-03-2014, 12:46 AM
  6. [SOLVED] Paste previously copied values as 123 except last one and...
    By intex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2014, 04:45 PM
  7. Replies: 0
    Last Post: 06-02-2006, 01:30 PM

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