Excel - Copy data from one sheet to another

October 2017

VBA code can be written to copy data from one Excel sheet to another instead of a macro. With a macro, if it is not written correctly, the same sheet will be copied to subsequent new sheets every time the macro is executed. Copying the Excel sheets manually will not be possible if the Excel sheet contained too much data.Writing code in VBA is simple and easy but it is not necessary to write the code from scratch. The code to copy data from one sheet to another can be downloaded legally from many programming resources.VBA code adds greater functionality to the Excel Office Software.

Issue


I am new to Macro in Excel and need help writing code to copy data from one sheet to another. I want to copy data from Sheet 1 of spreadsheet A to Sheet 1 of spreadsheet B whenever the former is updated, but without affecting the other sheets in spreadsheet B.

Solution


The following code will solve this problem. The sheet will update automatically.

Sub CopyPaste()      
Dim ws As Worksheet      
For Each ws In Worksheets      

If ws.Name <> "Master Sheet" Then      
ws.Select      
ws.Application.Run "Macro1"      
End If      
Next      
End Sub      

Sub Macro1()      
Range("A2:B13").Select      
Selection.Copy      
Sheets("Summary Sheet").Select      
ActiveSheet.Paste      
End Sub 

Note


Thanks to iveal for this tip on the forum.
Published by aakai1056. Latest update on February 13, 2012 at 08:17 PM by Paul Berentzen.
This document, titled "Excel - Copy data from one sheet to another," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).