format multiple sheets

F

FJDx

I set up the following example that is supposed to hide row 2 in sheets
1, 2 & 3:

' Macro1 Macro
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate
Rows("2:2").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
End Sub

However, when I run this, only row 2 in sheet 1 is hidden. How can I
amend this so that it formats a number of selected worksheets in the
same way. This would range between 2 and 25 worksheets at one time.
Format changes I require include sizes, fonts, page breaks, hide/unhide
row/columns etc.
 
R

Ron de Bruin

Try this

Sub test()
Dim sh As Worksheet
For Each sh In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
sh.Rows("2:2").EntireRow.Hidden = True
Next
End Sub

Use this for the selected sheets
For Each sh In ActiveWindow.SelectedSheets
 
F

FJDx

Ron de Bruin said:
Try this

Sub test()
Dim sh As Worksheet
For Each sh In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
sh.Rows("2:2").EntireRow.Hidden = True
Next
End Sub

Use this for the selected sheets
For Each sh In ActiveWindow.SelectedSheets

Thanks! I will give this a go.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top