Share via


How to: Programmatically copy data and formatting across worksheets

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

You can copy data from a range on one sheet to all the other sheets in a workbook by using the FillAcrossSheets method. Specify a range, and whether you want to copy data, formatting, or both.

Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.

Example

this.Application.ActiveWorkbook.Sheets.FillAcrossSheets(
    this.Application.get_Range("rangeData"), 
    Excel.XlFillWith.xlFillWithAll);
Me.Application.ActiveWorkbook.Sheets.FillAcrossSheets( _
    Me.Application.Range("rangeData"), Excel.XlFillWith.xlFillWithAll)

Compile the code

This example requires a range named rangeData in a worksheet.

See also