Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default View by User

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default View by User

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default View by User

How would I tie that to a user? For instance User 1 should see sheets A & B,
user 2 only A and user 3 only B.

"Jacob Skaria" wrote:

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default View by User

Private Sub Workbook_Open()
strUser = Environ("Username")
Select Case strUser
Case "John"
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Case "Peter", "Mary"
Sheets("Sheet1").Visible = False
Sheets("Sheet3").Visible = False
End Select
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

How would I tie that to a user? For instance User 1 should see sheets A & B,
user 2 only A and user 3 only B.

"Jacob Skaria" wrote:

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default View by User

The links below show how to use Windows API calls to get either the full name
or the login name of the user. You can put a call to one of these routines
in your workbook_open event and then compare that to your pre-defined list of
users to determine which sheets should be hidden or not.

http://www.mvps.org/access/api/api0066.htm
http://www.mvps.org/access/api/api0008.htm

Here is some code to help you get started. First, paste the code from the
above links into a regular code module in your workbook. Then, in the
Workbook module, enter the code below. This demonstrates how to get either
the login name or the full user name, along with some psuedo-code for setting
views based on which user has the file opened.

Private Sub Workbook_Open()
Dim theUser As String
'
' Use one or the other as required...
'
theUser = fGetFullNameOfLoggedUser()
MsgBox theUser
'
theUser = fOSUserName()
MsgBox theUser
'
Select Case theUser
Case "simpshj" ' login ID example
ActiveWorkbook.Sheets("Sheet1").Visible = True
ActiveWorkbook.Sheets("Sheet2").Visible = False
Case "Homer J Simpson" ' full name example
ActiveWorkbook.Sheets("Sheet1").Visible = True
ActiveWorkbook.Sheets("Sheet2").Visible = False
Case Else ' default view
ActiveWorkbook.Sheets("Sheet1").Visible = False
ActiveWorkbook.Sheets("Sheet2").Visible = True
End Select
'
End Sub

WARNING: I just thought of this. You may not be able to alter the
structure of the workbook (i.e. showing and hiding tabs) if it is a shared
file. You'll just have to experiment.

HTH,

Eric

"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default View by User

var1 = Range("A1:A10")
For Each strval In var1
Debug.Print strval
Next

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Private Sub Workbook_Open()
strUser = Environ("Username")
Select Case strUser
Case "John"
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Case "Peter", "Mary"
Sheets("Sheet1").Visible = False
Sheets("Sheet3").Visible = False
End Select
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

How would I tie that to a user? For instance User 1 should see sheets A & B,
user 2 only A and user 3 only B.

"Jacob Skaria" wrote:

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default View by User

Sorry this is posted wrongly..
--
If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

var1 = Range("A1:A10")
For Each strval In var1
Debug.Print strval
Next

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Private Sub Workbook_Open()
strUser = Environ("Username")
Select Case strUser
Case "John"
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Case "Peter", "Mary"
Sheets("Sheet1").Visible = False
Sheets("Sheet3").Visible = False
End Select
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

How would I tie that to a user? For instance User 1 should see sheets A & B,
user 2 only A and user 3 only B.

"Jacob Skaria" wrote:

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default View by User

Thanks!

"Jacob Skaria" wrote:

Private Sub Workbook_Open()
strUser = Environ("Username")
Select Case strUser
Case "John"
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Case "Peter", "Mary"
Sheets("Sheet1").Visible = False
Sheets("Sheet3").Visible = False
End Select
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

How would I tie that to a user? For instance User 1 should see sheets A & B,
user 2 only A and user 3 only B.

"Jacob Skaria" wrote:

You can use the workbook open event. Launch VBE using Alt+F11. Double click
on 'This Workbook'.Drop down to find Workbook open event.

Private Sub Workbook_Open()
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Pam M" wrote:

I have a workbook that will be shared that contains several worksheets.
Depending on the user, I want different sheets hidden from view upon opening
the workbook. Is there an easy way to do this?

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
View set to 'best fit' for User Adam Excel Discussion (Misc queries) 2 July 3rd 09 09:54 PM
User Choosing Which Columns to View Colin Vicary Excel Discussion (Misc queries) 3 June 29th 06 05:57 PM
specific user view G Excel Discussion (Misc queries) 0 January 24th 06 11:33 PM
Limiting view area to user jose luis Excel Programming 4 March 23rd 05 03:39 AM
Limiting view area to user jose luis Excel Programming 0 October 16th 04 12:27 AM


All times are GMT +1. The time now is 08:15 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"