Mocrosoft Excel Training Videos

Working with 3D ranges using a macro

Working with 3-D Ranges
If you are working with the same range on more than one sheet, use the Array function in Microsoft Excel to specify two or more sheets to select. The following macro example formats the border of a 3-D range of cells.

Sub FormatSheets()
Sheets(Array("Sheet2", "Sheet3", "Sheet5")).Select
Range("A1:E1").Select
Selection.Borders(xlBottom).LineStyle = xlDouble
End Sub
The macro below applies the FillAcrossSheets method to transfer the formats and any data from the range on Sheet2 to the corresponding ranges on all the worksheets in the active workbook.
Try this out!

Sub FillAll()
Worksheets("Sheet2").Range("A1:H1").Borders(xlBottom).LineStyle = xlDouble
Worksheets.FillAcrossSheets (Worksheets("Sheet2").Range("A1:H1"))
End Sub

Working with 3D ranges