![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi. Why don't you use visible properties of worksheets.
In order to display the sheet, an user must use vba. So like this time, I always use this properties. Please describe the following code to ThisWorkbook module. I assume that Sheet2 is a data sheet. Please change a sheet name according to your environment. 'ThisWorkbook module-----------from here--------------- Private Sub Workbook_SheetActivate(ByVal Sh As Object) Const pwd As String = "1111" If Sh.Name <> "Sheet1" Then Exit Sub If InputBox("Password Please") <> pwd Then Exit Sub With Sheets("Sheet2") .Visible = xlSheetVisible Application.Goto .Cells(1.1) End With End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) If Sh.Name <> "Sheet2" Then Exit Sub Sheets("Sheet2").Visible = xlSheetVeryHidden End Sub '------------------------------to here------------------ |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
I have a worksheet I keep the data hidden on. When the sheet is activated an input box asks for a password then the sheet is activated and the data seen. What I'm wanting is to add code to a macro that will unprotect the sheet so the macro can finish and then leave the sheet activated. I think I explained it okay.
I have a macro that will activate sheet 1 do its thing then activate the hidden sheet, my problem is that I'm using the input box and code to protect the sheet and not just the tools>protect sheet so I'm running into errors when I put ActiveSheet.Unprotect ("password") in my code. How can I supply the input box the password using a macro?
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|