Hiding rows when opening workbook

  • Thread starter Thread starter mardo
  • Start date Start date
M

mardo

Hi,

I'm trying to hide two sets of rows when the workbook opens.
Rows are in sheet 3, and those rows hides when the workbook opens.

My problem is that also same rows ( 41:47 and 51:54) hides in sheet 1.
Some cells in those rows in sheet 3 are linked to sheet 1.

I'm using this code placed in ThisWorkBook:

Sub Workbook_Open()
Worksheets(3).Activate
ActiveSheet.Rows("41:47").Select
Selection.EntireRow.Hidden = True
Worksheets(3).Activate
ActiveSheet.Rows("51:54").Select
Selection.EntireRow.Hidden = True
End Sub

So, what am I doing wrong here?

Regards, Mardo
 
try this

Sub Workbook_Open()
Worksheets(3).RANGE("41:47,51:54").EntireRow.Hidden = True
End Sub
 
Don gave you a solution I would expect to work. As to the cause, I would
suspect that you have sheets 1 and 3 both selected (you should see [group]
in the caption bar at the top of the workbook if you are windowed - or at the
top of the excel window if maximized).

Using your existing code, you could change
Worksheets(3).Activate

to
Worksheets(3).Select

if that is the problem. This will ungroup the sheets.

Unless there is a reason to group the sheets, I would ungroup them.
 
Back
Top