Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Hide Activesheet

Hi,

A variation on the hide a worksheet theme.

I have a series of worksheets (obviously with different names) accessed from
a central Navigation page. On each of the worksheets is a "Back" button that
returns the user to the Navigation page and hides the sheet.

Currently I have a different macro assigned to each back button that does
the same thing:

<name of current sheet here.Protect
Sheets(<name of current sheet here).Hidden = True
Sheets("Navigation Page").Select

What I would like to do is have a single macro that works for all sheets, so
it would look something like:

ActiveSheet.Protect
ActiveSheet.Hidden = True
Sheets("Navigation Page").Select

The only problem is I can't work out the syntax for the ActiveSheet lines.

Any help would be much appreciated.

TIA

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Hide Activesheet

Try this:-

Dim MySheet As Worksheet
Set MySheet = ActiveSheet
Sheets("Navigation Page").Select
MySheet.Protect
MySheet.Visible = xlSheetHidden
Set MySheet = Nothing
Sheets("Navigation Page").Activate

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Hi,

A variation on the hide a worksheet theme.

I have a series of worksheets (obviously with different names) accessed from
a central Navigation page. On each of the worksheets is a "Back" button that
returns the user to the Navigation page and hides the sheet.

Currently I have a different macro assigned to each back button that does
the same thing:

<name of current sheet here.Protect
Sheets(<name of current sheet here).Hidden = True
Sheets("Navigation Page").Select

What I would like to do is have a single macro that works for all sheets, so
it would look something like:

ActiveSheet.Protect
ActiveSheet.Hidden = True
Sheets("Navigation Page").Select

The only problem is I can't work out the syntax for the ActiveSheet lines.

Any help would be much appreciated.

TIA

Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Hide Activesheet

Alan,

Perfect - my thanks.

As a matter of interest, what does

Set MySheet = Nothing

do?

Dave

"Alan Moseley" wrote:

Try this:-

Dim MySheet As Worksheet
Set MySheet = ActiveSheet
Sheets("Navigation Page").Select
MySheet.Protect
MySheet.Visible = xlSheetHidden
Set MySheet = Nothing
Sheets("Navigation Page").Activate

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Hi,

A variation on the hide a worksheet theme.

I have a series of worksheets (obviously with different names) accessed from
a central Navigation page. On each of the worksheets is a "Back" button that
returns the user to the Navigation page and hides the sheet.

Currently I have a different macro assigned to each back button that does
the same thing:

<name of current sheet here.Protect
Sheets(<name of current sheet here).Hidden = True
Sheets("Navigation Page").Select

What I would like to do is have a single macro that works for all sheets, so
it would look something like:

ActiveSheet.Protect
ActiveSheet.Hidden = True
Sheets("Navigation Page").Select

The only problem is I can't work out the syntax for the ActiveSheet lines.

Any help would be much appreciated.

TIA

Dave


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Hide Activesheet

Every time you create a variable it uses up memory. Setting the variable
back to nothing frees up that memory.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Alan,

Perfect - my thanks.

As a matter of interest, what does

Set MySheet = Nothing

do?

Dave

"Alan Moseley" wrote:

Try this:-

Dim MySheet As Worksheet
Set MySheet = ActiveSheet
Sheets("Navigation Page").Select
MySheet.Protect
MySheet.Visible = xlSheetHidden
Set MySheet = Nothing
Sheets("Navigation Page").Activate

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Hi,

A variation on the hide a worksheet theme.

I have a series of worksheets (obviously with different names) accessed from
a central Navigation page. On each of the worksheets is a "Back" button that
returns the user to the Navigation page and hides the sheet.

Currently I have a different macro assigned to each back button that does
the same thing:

<name of current sheet here.Protect
Sheets(<name of current sheet here).Hidden = True
Sheets("Navigation Page").Select

What I would like to do is have a single macro that works for all sheets, so
it would look something like:

ActiveSheet.Protect
ActiveSheet.Hidden = True
Sheets("Navigation Page").Select

The only problem is I can't work out the syntax for the ActiveSheet lines.

Any help would be much appreciated.

TIA

Dave


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Hide Activesheet

Alan,

Thanks.

I'm still teaching myself this VB so it's good to pick up this points along
the way.

Dave

"Alan Moseley" wrote:

Every time you create a variable it uses up memory. Setting the variable
back to nothing frees up that memory.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Alan,

Perfect - my thanks.

As a matter of interest, what does

Set MySheet = Nothing

do?

Dave

"Alan Moseley" wrote:

Try this:-

Dim MySheet As Worksheet
Set MySheet = ActiveSheet
Sheets("Navigation Page").Select
MySheet.Protect
MySheet.Visible = xlSheetHidden
Set MySheet = Nothing
Sheets("Navigation Page").Activate

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Risky Dave" wrote:

Hi,

A variation on the hide a worksheet theme.

I have a series of worksheets (obviously with different names) accessed from
a central Navigation page. On each of the worksheets is a "Back" button that
returns the user to the Navigation page and hides the sheet.

Currently I have a different macro assigned to each back button that does
the same thing:

<name of current sheet here.Protect
Sheets(<name of current sheet here).Hidden = True
Sheets("Navigation Page").Select

What I would like to do is have a single macro that works for all sheets, so
it would look something like:

ActiveSheet.Protect
ActiveSheet.Hidden = True
Sheets("Navigation Page").Select

The only problem is I can't work out the syntax for the ActiveSheet lines.

Any help would be much appreciated.

TIA

Dave


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Excel Programming 2 June 2nd 08 08:09 PM
error 438 on ActiveSheet.Columns(16).Hide? The ants are driving me crazy Excel Programming 1 January 11th 07 07:40 PM
Copying new activesheet after other activesheet is hidden? Simon Lloyd[_790_] Excel Programming 1 June 20th 06 10:02 AM
ActiveSheet.Name? Andrew Stedman Excel Programming 5 July 30th 03 01:17 PM
ActiveSheet Graham[_3_] Excel Programming 0 July 29th 03 04:47 PM


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"