• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

username and password

gopikrishna

New Member
Dear All ,

I have an excel file with number of sheets(5). I wanted to create username/password combination so that when a person types usename/password the sheet applicable to him opens. Pl help
 
Hi Gopikrishna,


Here is the macro to it.


Suppose you have spreadsheets like Kiran, Rohith....


example:

Login details for Kiran sheet is:

Username : Kiran

Password: kiran123


''''Macro


Sub User_Password()


x = InputBox("Enter User Name")

y = InputBox("Enter Password")


If x = "Kiran" And y = "kiran123" Then

Sheets("Kiran").Visible = xlSheetVisible

Exit Sub

Else

MsgBox "Incorrect password"

Exit Sub

End If


If x = "Rohith" And y = "rohith123" Then

Sheets("Rohith").Visible = xlSheetVisible

Exit Sub

Else

MsgBox "Incorrect password"

Exit Sub

End If

End Sub


''''Macro End


And one more, you need a veryhidden option once they close the excel file.


Private Sub Workbook_BeforeClose(Cancel As Boolean)

Worksheets("Kiran").Visible = xlSheetVeryHidden

Worksheets("Rohith").Visible = xlSheetVeryHidden


End Sub


Regards,

KK
 
Back
Top