Macro to type in worksheet password

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7
I am trying to create a macro that will allow me to unprotect a password protected worksheet. I do not want the password to show in the macro itself except as *s. I know I have seen this discussed somewhere I just can't remember where.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,002
Office Version
  1. 365
  2. 2016
Hi Lynnette

Welcome to the Board

Do you mean setting the password character to * or something else in a text box? If so you need to look in Properties for PasswordChar and set it to your desired character

HTH


Dave
 

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7
I wanted to be able to type in a normal password, but if you read the documentation for the macro, the actual password would not show in the macro, only * or other characters.
 

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,002
Office Version
  1. 365
  2. 2016
Can you show the documentation please?
 

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7

ADVERTISEMENT

Hi Lynnette

Welcome to the Board

Do you mean setting the password character to * or something else in a text box? If so you need to look in Properties for PasswordChar and set it to your desired character

HTH


Dave
What I am trying to do is type the actual password in, but when you look at the macro itself, the actual password is not there just *s or other characters.
 

Lynnette

New Member
Joined
Apr 1, 2009
Messages
7
Can you show the documentation please?
Sub Macro1()
Here is the docuemntation for one we created, we are working on another right now and do not want the password in the documentation.

' Macro1 Macro
' Macro recorded 2/4/2009 by Robert Ragusin
'
'
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Next.Select
ActiveSheet.Unprotect Password:="checks"
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select


End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2/4/2009 by Robert Ragusin
'
'
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Next.Select
ActiveSheet.Protect "checks"
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select
ActiveSheet.Previous.Select

End Sub
 

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,002
Office Version
  1. 365
  2. 2016
Right

Code:
Sub UnProAll()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Sheets
    sh.Unprotect "Password"
Next sh
End Sub

And Protect to do the reverse as for not having the password in the code, this is not possible as far as I am aware, you should protect the VBA Project to hide the password
 

Watch MrExcel Video

Forum statistics

Threads
1,123,535
Messages
5,602,217
Members
414,513
Latest member
junbuggle

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
Top