VBA example - Excel 2007: copy content of a sheet

VBA code to copy content of a sheet

When you work with multiple worksheets in Excel, you may want to copy the content of a worksheet to other worksheets. To copy the content across the worksheets with VBA code, you can use the FillAcrossSheets() method of the worksheet object. In this VBA code example, the content of the Sheet1 in range A1:A10 will be copies and pasted in the same range of the Sheet2 and Sheet3.

To run this VBA code example, you need a Form and a CommandButton.

VBA code to copy content of worksheet to other worksheets

VBA code for this example:

Private Sub CommandButton1_Click()
    Dim sh() As Variant

    sh = Array("Sheet1", "Sheet2", "Sheet3")

    Worksheets(sh).FillAcrossSheets Sheets("Sheet1").Range("A1:A10")


End Sub


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.