+ Reply to Thread
Results 1 to 5 of 5

Copy Data from One worksheet to Another without Overwrite

  1. #1
    Registered User
    Join Date
    08-22-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    3

    Copy Data from One worksheet to Another without Overwrite

    Hi All,

    I m trying to find a way to get a VBA code for Copying the data from one excel sheet to another without overwriting the existing data. I did try with many different sample codes available but for some reason most of them are just copying a specified cells and rows. What I m trying to find is from column A to J I would have 3000 to 4000 odd data every week and I have placed a macro to update the sheet with the weekly data. but then I need to copy that data lets say from Sheet 1 to Sheet 2 which already has previous years data. I want the macro to copy the data from sheet 1 to sheet 2 on the next available bank cell from A to J column. Can you please help me out in this. Thanks in advance.

    Cheers
    Vinu

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy Data from One worksheet to Another without Overwrite

    Try something like this.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-22-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy Data from One worksheet to Another without Overwrite

    That was too cool. Thanks Mate its worked well and I m done with my Report with all marcos ....

  4. #4
    Registered User
    Join Date
    08-22-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy Data from One worksheet to Another without Overwrite

    Please find my final code I used. Even though I have selected the A2 as the primary cell for copying the data to another sheet without overwrite. But the data gets copied from A1 cell " Sheets("dest").Range("A2").CurrentRegion.Resize(, 10).Copy
    Sheets("YTD Details").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
    Application.CutCopyMode = False"

    is there anyway to change the Cell range from A1 to A2?

    Final Code -

    Sub Consolidate()
    Dim sourceSheet As Worksheet
    Dim destSheet As Worksheet

    '' copy from the source
    Workbooks.Open Filename:="E:\Vinodh\Working\Bag Report\Source.XLS"
    Set sourceSheet = Worksheets("source")
    sourceSheet.Activate
    sourceSheet.Cells.Select
    Selection.Copy

    '' paste to the destination
    Workbooks.Open Filename:="E:\Vinodh\Working\Excel Automation\destination.xls"
    Set destSheet = Worksheets("dest")
    destSheet.Activate
    destSheet.Cells.Select
    destSheet.Paste

    '' save & close
    ActiveWorkbook.Save

    Sheets("dest").Range("A2").CurrentRegion.Resize(, 10).Copy
    Sheets("YTD Details").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
    Application.CutCopyMode = False

    Sheets("YTD Summary").Select
    Range("A23").Select
    ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
    Sheets("Weekly Summary").Select
    Range("E16").Select
    ActiveWindow.SmallScroll Down:=-21
    Sheets("dest").Select
    Range("L672").Select
    ActiveWorkbook.Save


    End Sub

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy Data from One worksheet to Another without Overwrite

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    This copies from the source sheet to Worksheets("YTD Details") without the header row 1 . No need to use the intermediary sheet "dest" unless I'm misunderstanding something.

    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. [SOLVED] Copy/Paste from a Filtered Range and Insert copied data NOT overwrite
    By Simon.Ward in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-12-2013, 11:14 AM
  2. [SOLVED] Copy worksheet from one WB to another, overwrite existing worksheet with same CodeName
    By Renns in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-31-2012, 10:30 AM
  3. Prevent data cell overwrite but allow blank cell overwrite
    By Squasher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2011, 09:24 AM
  4. Replies: 1
    Last Post: 08-30-2005, 08:05 PM
  5. Worksheet Overwrite Macro Change
    By biojunkie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2005, 08:05 PM

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