macro question
MZ Tools makes life easier for the Excel VBA coder
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: macro question

  1. #1
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default

     
    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. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com