Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50123

Hide Worksheet Macro shows data before password prompt

$
0
0
Just getting my feet wet with Macros, need some help with one I found on the web.

I use a macro that hides data on a worksheet yet keeps that sheet tab visible. When I need to access the tab, it prompts for a password. See attached sample file. Password is "password" (no quotes).

Works well but when I click on the tab of the 'hidden sheet' the data flashes on screen momentarily as the password prompt appears. Worse yet, if you click and hold on the 'hidden sheets' tab, the data stays visible until your release the mouse button.


How do I get the data to NOT appear when accessing the hidden sheet?

Here's what we have:

Code:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
 MySheet = "Sheet1"
 If ActiveSheet.Name = MySheet Then
 ActiveSheet.Visible = False
    response = InputBox("Enter password to view sheet")
        If response = "password" Then
            Sheets(MySheet).Visible = True
            Application.EnableEvents = False
            Sheets(MySheet).Select
            Application.EnableEvents = True
        End If
 End If
 Sheets(MySheet).Visible = True
 End Sub


Thanks, Steve

Macro Credit to Mike H, at
<http://answers.microsoft.com/en-us/office/forum/office_2003-excel/hiding-a-spreadsheet-within-a-workbook/1159ad78-ca37-4bf7-83a4-ab87667c994f>
Attached Files

Viewing all articles
Browse latest Browse all 50123

Trending Articles