Bagikan melalui


How to: Copy Data and Formatting across Worksheets

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Excel 2003

  • Excel 2007

For more information, see Features Available by Application and Project Type.

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

Example

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

Compiling the Code

This example requires a range named rangeData in a worksheet.

See Also

Tasks

How to: Add New Worksheets to Workbooks

How to: Change Formatting in Worksheet Rows Containing Selected Cells

Concepts

Working with Worksheets

The Variable missing and Optional Parameters in Office Solutions