C
Chris
I have the following code below located in the 'This Workbook'. This
code works great for hiding worksheets from certian users but I have a
situation now where I need to hide certain columns in "worksheet2" from
certain users. I am not sure if I have to add some sort of hide columns
code to
'worksheet2' or if I can somehow add it to the below code somwhere. I
am still pretty much a beginner, so any detailed answer on what exaclt
yI have to do would be very helpful. Thanks.
Private Sub Workbook_Open()
Application.ScreenUpdating = False
FrontpageFirst
On Error Resume Next
sStr = fOSUserName()
x = sStr
Select Case x
Case "chris"
Worksheets("worksheet1").Visible = True
Worksheets("worksheet2").Visible = True
Worksheets("worksheet3").Visible = True
Case Else
For i = 2 To Worksheets.Count
Worksheets(i).Visible = xlVeryHidden
Next
End Select
Worksheets(2).Activate
Worksheets(1).Visible = xlVeryHidden
Application.ScreenUpdating = False
Dim cb As CommandBar
CreateMenuBar NewCommandBar
End Sub
Sub FrontpageFirst()
Dim page As String
page = "Unauthorized"
On Error Resume Next
Worksheets(page).Visible = True
If Worksheets(1).Name = page Then
Worksheets(1).Activate
Else
Worksheets(page).Activate
If Err = 0 Then
ActiveSheet.Move before:=Worksheets(1)
Else
Worksheets.Add before:=Worksheets(1)
Worksheets(1).Name = page
End If
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
FrontpageFirst
For i = 2 To Worksheets.Count
Worksheets(i).Visible = xlVeryHidden
Next
Application.DisplayAlerts = True
ActiveWorkbook.Save
Application.DisplayAlerts = False
On Error Resume Next
End Sub
code works great for hiding worksheets from certian users but I have a
situation now where I need to hide certain columns in "worksheet2" from
certain users. I am not sure if I have to add some sort of hide columns
code to
'worksheet2' or if I can somehow add it to the below code somwhere. I
am still pretty much a beginner, so any detailed answer on what exaclt
yI have to do would be very helpful. Thanks.
Private Sub Workbook_Open()
Application.ScreenUpdating = False
FrontpageFirst
On Error Resume Next
sStr = fOSUserName()
x = sStr
Select Case x
Case "chris"
Worksheets("worksheet1").Visible = True
Worksheets("worksheet2").Visible = True
Worksheets("worksheet3").Visible = True
Case Else
For i = 2 To Worksheets.Count
Worksheets(i).Visible = xlVeryHidden
Next
End Select
Worksheets(2).Activate
Worksheets(1).Visible = xlVeryHidden
Application.ScreenUpdating = False
Dim cb As CommandBar
CreateMenuBar NewCommandBar
End Sub
Sub FrontpageFirst()
Dim page As String
page = "Unauthorized"
On Error Resume Next
Worksheets(page).Visible = True
If Worksheets(1).Name = page Then
Worksheets(1).Activate
Else
Worksheets(page).Activate
If Err = 0 Then
ActiveSheet.Move before:=Worksheets(1)
Else
Worksheets.Add before:=Worksheets(1)
Worksheets(1).Name = page
End If
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
FrontpageFirst
For i = 2 To Worksheets.Count
Worksheets(i).Visible = xlVeryHidden
Next
Application.DisplayAlerts = True
ActiveWorkbook.Save
Application.DisplayAlerts = False
On Error Resume Next
End Sub