ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding rows when opening workbook (https://www.excelbanter.com/excel-programming/358308-hiding-rows-when-opening-workbook.html)

[email protected]

Hiding rows when opening workbook
 
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


Don Guillett

Hiding rows when opening workbook
 
try this

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


--
Don Guillett
SalesAid Software

wrote in message
oups.com...
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




[email protected]

Hiding rows when opening workbook
 
Thanks, but

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


Mardo


Tom Ogilvy

Hiding rows when opening workbook
 
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.

--
Regards,
Tom Ogilvy


" wrote:

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




All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com