Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Any way to show / hide sheets

I need a way, when i open a workbook, to hide all sheets till the user enter
the correct password.
When the user enter the password i want be able to show all sheets.
Please, someone can help me?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Any way to show / hide sheets

On May 6, 8:34*pm, SteAXA wrote:
I need a way, when i open a workbook, to hide all sheets till the user enter
the correct password.
When the user enter the password i want be able to show all sheets.
Please, someone can help me?
Thanks

I tried the following to make a sheet hidden
Try same with some modifications for your need
But i think u must make at least one sheet active
cannot hide all sheets
U can do that for a extra blank sheet
IF u need to hide all the sheets then u can set the password to open
THat will be useful then VBA code
The following code should be in the workbook.

Dim sLast As Object



Private Sub Workbook_Open()

'Ensure Sheet1 is not the active sheet upon opening.

If Sheet1.Name = ActiveSheet.Name Then Sheet2.Select

End Sub



Private Sub Workbook_SheetActivate(ByVal Sh As Object)

pwd = Sheet1.Range("a2").Text 'this is the password to open the file

Dim strPass As String

Dim lCount As Long



If Sh.CodeName < "Sheet1" Then

'Set sLast variable to the last active sheet _

' This is then used to return the user to the _

' last sheet they were on if password is not known _

' or they Cancel.

Set sLast = Sh



Else

'Hide Columns

Sheet1.Columns.Hidden = True

'Allow 3 attempts at password

For lCount = 1 To 3

strPass = InputBox(Prompt:="Password Please" &
vbNewLine _
& "Password is case sensitive. Attempt " & lCount & "
of 3.", Title:="PASSWORD REQUIRED")

If strPass = vbNullString Then 'Cancelled

sLast.Select

Exit Sub

ElseIf strPass < pwd Then 'InCorrect password

MsgBox "Password incorrect", vbCritical,
"Subodh"

Else 'Correct Password

Exit For

End If

Next lCount



If lCount = 4 Then 'They use up their 3 attempts

sLast.Select

Exit Sub

Else 'Allow viewing

Sheet1.Columns.Hidden = False

End If

End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Any way to show / hide sheets

I forget to say you that i read the password from a database and the password
depends on the user name.
So, i can't use the excel password (tools/options) for protect workbook.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Any way to show / hide sheets

No need answer i found it. Sometimes i forget that the macro can help me!
Excuse me for the post!

"SteAXA" wrote:

I need a way, when i open a workbook, to hide all sheets till the user enter
the correct password.
When the user enter the password i want be able to show all sheets.
Please, someone can help me?
Thanks

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
Show zero value but hide NA KateB Charts and Charting in Excel 4 June 3rd 10 03:25 AM
Hide all sheets but selected sheets - an example [email protected] Excel Programming 1 April 7th 06 06:29 PM
Show / Hide Columns in multiple sheets Shadster Excel Programming 2 June 27th 05 12:09 PM
Hide/show sheets by first part of sheet name Brentus Excel Programming 2 September 15th 04 06:21 AM
Show Form, Hide all Sheets John Pierce Excel Programming 2 June 10th 04 10:42 AM


All times are GMT +1. The time now is 01:54 AM.

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

About Us

"It's about Microsoft Excel"