Excel - Copy data from one sheet to another

August 2016

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.

See also :

This document entitled « Excel - Copy data from one sheet to another » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.