Hiding rows when opening workbook

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
 
D

Don Guillett

try this

Sub Workbook_Open()
Worksheets(3).RANGE("41:47,51:54").EntireRow.Hidden = True
End Sub
 
M

mardo

Thanks, but

the problem is still there. Rows 41:47 and 51:54 hids from sheet1.


Mardo
 
T

Tom Ogilvy

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.
 

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