Password Protecting 2 worksheets from viewing

Ejimenez

New Member
Joined
Nov 10, 2012
Messages
14
Hello!!


I am trying to password protect 2 worksheets using VB. I have started the coding but the forum box is not disappearing after the user inputs the correct or incorrect password.

I hope you can help.

I want the userforum box to appear as soon as the workbook is open.

Here is what I have so far.


Private Sub workbook_before(cancel As Boolean)
Sheets("Score Weight").Visible = False
Sheets("Summary").Visible = False
End Sub

Private Sub Workbook_Open()
Administrator.Show
End Sub


Sub CommandButton2_Click()
If (TextBox1.Value = "hawkeye") Then

Sheets("Score Weight").Visible = True
Sheets("Summary").Visible = True
Sheets("Partner Score Form").Select

Else
Sheets("Score Weight").Visible = False
Sheets("Summary").Visible = False

retry = MsgBox("The Password is incorrect. Do you wish to try again?", vbYesNo, "Retry?")
Select Case retry
Case Is = vbYes
TextBox1.Value = ""
TextBox1.SetFocus
Show

Case Is = vbNo
Show
End Select
End If

End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this

Sheets("Score Weight").Visible = True
Sheets("Summary").Visible = True
Unload Me 'closes the form
Sheets("Partner Score Form").Select
 
Upvote 0
Thank you for the reply.

I added that Unload me to my code however, How to I made the forum appear as soon as the workbook gets open. It doesn't appear?
 
Upvote 0
I'm pretty sure this is the right code


Private Sub Workbook_Open()
Administrator.Show
End Sub


Do you have that in the "ThisWorkbook" module?
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top