I did as you described and this is what I found (Win 2000, XL 2000):
The original recording did not work, as you said:
Sub test() 'this doesn't work
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate
Range("A1").Select
Selection.Font.Bold = True
End Sub
However, eliminating the second line made it work as you'd want:
Sub test() 'this works
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Range("A1").Select
Selection.Font.Bold = True
End Sub
Strangely, if I try to condense it further to avoid selecting a range, it
doesn't work again:
Sub test() 'this doesn't work
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Range("A1").Font.Bold = True
End Sub
Ultimately, will probably want to look at formatting a collection of sheets,
using the for-each construct, e.g.,
Sub test()
Dim sh As Worksheet
For Each sh In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
sh.Range("A1").Font.Bold = True
Next sh
End Sub
hth (at least a little),
Doug
DrDave1958 said:
If I turn on the macro recorder, then select sheets 3 thru 10 (group),
then go to file, page setup, and make the changes I desire, the changes are
applied to all sheets selected. When I run the VBA code I just recorded, it
only formats the active sheet. What am I doing wrong?