PC Review


Reply
Thread Tools Rate Thread

How to determine which sheets appear on opening a workbook.

 
 
Glenn
Guest
Posts: n/a
 
      22nd Mar 2010
Is it possible to determine which sheets appear when a workbook is opened. I
have a workbook with a number of hidden sheets that are updated by me from
time to time and I would like them to start off hidden when the workbook is
opened by say, someone else on the network. I have toyed with the Workbook
Open in VB but to no avail. Many thanks

Glenn
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Mar 2010
if i understand correctly, maybe something like this in the workbook open
event

Private Sub Workbook_Open()
If UCase(Environ("username")) = "GLENN" Then
Worksheets("sheet1").Visible = True
Else
Worksheets("sheet1").Visible = False
End If
End Sub

--


Gary Keramidas
Excel 2003


"Glenn" <(E-Mail Removed)> wrote in message
news:B9F28BDF-7577-4F24-980F-(E-Mail Removed)...
> Is it possible to determine which sheets appear when a workbook is opened.
> I
> have a workbook with a number of hidden sheets that are updated by me from
> time to time and I would like them to start off hidden when the workbook
> is
> opened by say, someone else on the network. I have toyed with the
> Workbook
> Open in VB but to no avail. Many thanks
>
> Glenn


 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      22nd Mar 2010
No problem. Hit Alt+F11. Under Project-VBA Project, you will see a small
file named 'ThisWorkbook'. Double-click and copy/paste the following code
into the window that opens:
Private Sub Workbook_Open()
Worksheets("Example").Activate
End Sub

"Example" is the name of the worksheet that you want open when the workbook
opens, so change this to suit your specific needs.


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Glenn" wrote:

> Is it possible to determine which sheets appear when a workbook is opened. I
> have a workbook with a number of hidden sheets that are updated by me from
> time to time and I would like them to start off hidden when the workbook is
> opened by say, someone else on the network. I have toyed with the Workbook
> Open in VB but to no avail. Many thanks
>
> Glenn

 
Reply With Quote
 
Glenn
Guest
Posts: n/a
 
      22nd Mar 2010
Many thanks. Just tried it. It made the sheet I want active but, didn't
make it the only sheet visible which is my ultimate aim.

"ryguy7272" wrote:

> No problem. Hit Alt+F11. Under Project-VBA Project, you will see a small
> file named 'ThisWorkbook'. Double-click and copy/paste the following code
> into the window that opens:
> Private Sub Workbook_Open()
> Worksheets("Example").Activate
> End Sub
>
> "Example" is the name of the worksheet that you want open when the workbook
> opens, so change this to suit your specific needs.
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "Glenn" wrote:
>
> > Is it possible to determine which sheets appear when a workbook is opened. I
> > have a workbook with a number of hidden sheets that are updated by me from
> > time to time and I would like them to start off hidden when the workbook is
> > opened by say, someone else on the network. I have toyed with the Workbook
> > Open in VB but to no avail. Many thanks
> >
> > Glenn

 
Reply With Quote
 
Gary Brown
Guest
Posts: n/a
 
      22nd Mar 2010
Give this a show Glenn...

Private Sub Workbook_Open()
Dim wks As Worksheet

Worksheets("Sheet1").Activate

For Each wks In Worksheets
If wks.Name <> "Sheet1" Then
wks.Visible = xlSheetHidden
End If
Next wks

End Sub

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Glenn" wrote:

> Many thanks. Just tried it. It made the sheet I want active but, didn't
> make it the only sheet visible which is my ultimate aim.
>
> "ryguy7272" wrote:
>
> > No problem. Hit Alt+F11. Under Project-VBA Project, you will see a small
> > file named 'ThisWorkbook'. Double-click and copy/paste the following code
> > into the window that opens:
> > Private Sub Workbook_Open()
> > Worksheets("Example").Activate
> > End Sub
> >
> > "Example" is the name of the worksheet that you want open when the workbook
> > opens, so change this to suit your specific needs.
> >
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.
> >
> >
> > "Glenn" wrote:
> >
> > > Is it possible to determine which sheets appear when a workbook is opened. I
> > > have a workbook with a number of hidden sheets that are updated by me from
> > > time to time and I would like them to start off hidden when the workbook is
> > > opened by say, someone else on the network. I have toyed with the Workbook
> > > Open in VB but to no avail. Many thanks
> > >
> > > Glenn

 
Reply With Quote
 
Glenn
Guest
Posts: n/a
 
      22nd Mar 2010
Surperb. It works a treat. Many thanks

Glenn

"Gary Brown" wrote:

> Give this a show Glenn...
>
> Private Sub Workbook_Open()
> Dim wks As Worksheet
>
> Worksheets("Sheet1").Activate
>
> For Each wks In Worksheets
> If wks.Name <> "Sheet1" Then
> wks.Visible = xlSheetHidden
> End If
> Next wks
>
> End Sub
>
> --
> Hope this helps.
> If it does, please click the Yes button.
> Thanks in advance for your feedback.
> Gary Brown
>
>
>
> "Glenn" wrote:
>
> > Many thanks. Just tried it. It made the sheet I want active but, didn't
> > make it the only sheet visible which is my ultimate aim.
> >
> > "ryguy7272" wrote:
> >
> > > No problem. Hit Alt+F11. Under Project-VBA Project, you will see a small
> > > file named 'ThisWorkbook'. Double-click and copy/paste the following code
> > > into the window that opens:
> > > Private Sub Workbook_Open()
> > > Worksheets("Example").Activate
> > > End Sub
> > >
> > > "Example" is the name of the worksheet that you want open when the workbook
> > > opens, so change this to suit your specific needs.
> > >
> > >
> > > --
> > > Ryan---
> > > If this information was helpful, please indicate this by clicking ''Yes''.
> > >
> > >
> > > "Glenn" wrote:
> > >
> > > > Is it possible to determine which sheets appear when a workbook is opened. I
> > > > have a workbook with a number of hidden sheets that are updated by me from
> > > > time to time and I would like them to start off hidden when the workbook is
> > > > opened by say, someone else on the network. I have toyed with the Workbook
> > > > Open in VB but to no avail. Many thanks
> > > >
> > > > Glenn

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      22nd Mar 2010
I would hide the sheets before close so's if users disable macros the sheets
will be hidden.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
sht.Visible = xlSheetVeryHidden
Next sht
End Sub

To allow you to see all sheets and edit them.

In a general module...............

Sub UnHideAllSheets()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Visible = True
Next n
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP


On Mon, 22 Mar 2010 08:08:01 -0700, Glenn <(E-Mail Removed)>
wrote:

>Is it possible to determine which sheets appear when a workbook is opened. I
>have a workbook with a number of hidden sheets that are updated by me from
>time to time and I would like them to start off hidden when the workbook is
>opened by say, someone else on the network. I have toyed with the Workbook
>Open in VB but to no avail. Many thanks
>
>Glenn


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening multiple txt files into one workbook as separate sheets tbraddy Microsoft Excel Discussion 2 23rd Apr 2008 08:28 PM
Opening a list of workbooks with vba, similar to going through sheets in a workbook? Ron Microsoft Excel Programming 3 17th Apr 2006 02:11 PM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork Microsoft Excel Programming 6 26th Jan 2006 06:31 PM
In 3 active sheets in wkbk, determine& display the # of sheets that have data wrpalmer Microsoft Excel Misc 1 4th Nov 2005 02:01 PM
run code on opening workbook and apply code to certain sheets =?Utf-8?B?SmFuZQ==?= Microsoft Excel Programming 7 8th Aug 2005 09:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:49 AM.