Password Protect/Unprotect Dialog Macro??? !

Mar 4, 2007

Stumbling over syntax on what should be easy. I want to password protect the active sheet using plain vanilla user input box; and then unprotect ALSO via an input box. Doesn't matter about masking the input with **** or whatever. Based on responses below, here is macro code I used:

To protect the sheet:

Sub ProtectSecurity()
Dim pword As String
pword = InputBox("Enter Password", "Password")
ActiveSheet.Protect pword
End Sub
---------------------------------
To Unprotect the sheet:

Sub UnprotectSecurity()
Dim pword As String
pword = InputBox("Enter Password", "Password")
ActiveSheet.Unprotect pword
End Sub

View 5 Replies


ADVERTISEMENT

Macro To Unprotect Sheet Unlock Cells And Protect Worksheet With Same Password

Jan 23, 2012

I have been really trying to get this sorted myself and I can get it to work with one exception. I can't get the sheet to lock with a password. It locks, but if I try to unlock it again, it does so without prompting me to enter a password.

Essentially I am wanting to unprotect two sheets, unlock the cells that were previously locked (so users couldn't enter data in them when the sheet is protected), then reapply the same password to protect the sheet, but now they will be able to enter data in the unlocked range of cells).

The second macro is to reverse the changes made in the first and 're-lock' the unlocked cells) (and again apply the same password to the sheet).

this is the code I have used.

Sub PART_YEAR()

Sheets("2012 Calculator 1 week").Select
ActiveSheet.Unprotect "taado"
Range("D20:D23").Select
Selection.Locked = False
Selection.FormulaHidden = False
Sheets("2012 Calculator 2 week").Select

[Code]...

I am assuming I have superfluous code in there, in addition to my mistake with the reapplication of the password.

View 3 Replies View Related

Unprotect & Protect All Sheets With Password

Dec 21, 2006

I have a series of workbooks where multiple users are entering data. Most of the cells are locked, and the worksheets are password protected. From time to time, I have to make global changes to all the workbooks. I've recorded a macro to open all the workbooks, but now, I'm running into a problem because for speed, I'd like to unprotect the worksheets and "re-protect" them without having to enter the password 3 million times (exagerration, but not much). What is the proper syntax of code to have VBA enter the password automatically (it is the same for all sheets).

View 4 Replies View Related

Protect And Unprotect All Sheets And Workbook Using Userform Interface And Password

Jul 6, 2012

I am trying to create a way to protect and unprotect all sheets and the worbook by means of a Userform pop up interface.

I have managed to create the Userform but what the code will look like and where to place the VBA code that will make it work, Also i would like to automatically save the sheet/s as i switch between them. so that any updates made to the sheet will be automatically saved when i move to the next sheet and also when i protect or close the workbook.

View 3 Replies View Related

Password Protect: Unlock The Worksheet, Autofilter It, Print It, Unfilter It, And Password Protect The Sheet Again?

Jan 12, 2007

I have a sheet that is password protected. I have this code attached to a command button. It will unlock the worksheet, autofilter it, print it, unfilter it, and password protect the sheet again. However it is protecting it without a password. I need to have it protected with the password so that someone will not be able to just go to tools to unprotect the sheet.

Private Sub CommandButton1_Click()
ActiveSheet.Unprotect "rainforest"
Columns("O:O").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=">0", Operator:=xlAnd
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=1
Selection.AutoFilter
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
End Sub

View 3 Replies View Related

Using Macro To Protect And Unprotect Worksheets

Oct 23, 2008

I am looking for a way to protect and unprotect all worksheets with a password through a macro. I have excel 2007.

View 2 Replies View Related

Macro: Protect & Unprotect Sheets

Nov 9, 2006

Is there an easy way (using a macro) to unprotect and protect sheets?

Most sheets in a certain workbook are protected except a few cells that are open for manual entry. Because I have links to other cells in other workbooks, I must unprotect those sheets/fields before I can edit the links. And I MUST ensure all sheets are protected again when I'm done with my work.

Also, is it possible to password-protect that specific macro so I'm the only one who can run it to unprotect and protect?

View 9 Replies View Related

Unprotect Worksheet Macro With Password

Dec 31, 2004

Here is my macro, how do I add the password to make it work properly?

Sub unprotect()
' unprotect Macro
' Macro recorded 12/30/2004 by '

ActiveSheet.unprotect
ActiveWorkbook.unprotect
End Sub

Both the sheet and the workbook are protected and use the same password

jiuk - code tags added

View 4 Replies View Related

Code To UNPROTECT Then PROTECT Workbook When Macro Runs

Jul 24, 2014

Okay, I have this code and it works very well - but it only works if my WORKBOOK is unprotected. I know how to Unprotect then Protect an ActiveSheet, but I can't figure out how to Unprotect then Protect my workbook when the macro runs..

Sub BLM_RENAME_SHEET()
Dim WS As Worksheet
Application.ScreenUpdating = False
For Each WS In ActiveWindow.SelectedSheets

[Code] ......

View 9 Replies View Related

Workbook Enable Macro Protect / Unprotect The Sheet

Sep 4, 2009

I need a macro that I can have in any workbook enabling me to protect / unprotect the workbook that I have currently opened with a set password (let say "Password")

I would link this macro to a button in excel 2002. I have try the following but it doesnt work

Would it be possible that the button (first) works (second) understand whether or not protect / unprotected and do the opposite?

Sub Protect
Activeworkbook.protect password:="password", structure:=FALSE, Windows:=false
End Sub

View 9 Replies View Related

Excel 2003 :: Unprotect And Protect Multiple Works Sheets With Macro?

Feb 25, 2008

I have an annual leave (vacation) work book with a summary page work sheet and separate work sheets for each month i.e. Jan, Feb, Mar.....to......Dec. In order to protect the formulas I have protected them by allowing only access to the input cells on each work sheet and the protect each work sheet.

When someone either joins or leaves the team I have to manually unprotect each sheet and protect again when I have completed the amendments to each of the 13 tabs.

macro code I would need to unprotect all the works sheets in one go (as I use the same password for all the sheets) and reset the passwords (protect) the sheets with more macro code.

I will be running the two macros from my own personal.xls file and ideally they would be fully automatic i.e. I would not need to input the passwords in to unlock or lock the work sheets as the password would be written in the code already

Excel version 2003

View 3 Replies View Related

Protected Sheet - Macro To Unprotect, Refresh Sql Query & Re-protect Fails

Feb 21, 2007

I have a protected worksheet containing an SQL query. I have two cells on the worksheet unlocked so that users can enter fresh parameters to feed the query.
Because I have to use MS Query to interrogate our SQL server (current IT decree), the query won't support parameters directly when the query cannot be represented graphically - so I have to manually edit the sql command text and then refresh the query - or at least that was why I wrote the code below

The problem: My macro won't unprotect the sheet before it calls the SQL.it therefore won't update the sheet to detail the DSN, command text and number of parameters (latter should be 0) - info just used to verify queryit won't run the query / return the data as the sheet is still protected Comment: I have had to remove sheet protection in order to allow the sql to execute and return data. If protection is removed, the query does execute and return data ( changes in the "parameter" cell contents do cause the query to be correctly modified)
I could comment out the debug info but the query still doesn't return data if the sheet is protected.

Activesheet And worksheets(ndx) where ndx has been defined As ActiveSheet.Name
I apologise If my post Is difficult To follow - especially the code.

Sub AgedStockParameters()
nmb = ActiveWorkbook.Name
ndx = ActiveSheet.Name
Workbooks(nmb).Activate
Worksheets(ndx).Activate
ActiveSheet.Range("A1").Select
WkshtQryCon = Workbooks(nmb).Worksheets(ndx).QueryTables(1).Connection
ActiveCell.Value = WkshtQryCon
Range("A2").Select
WkshtQryFld = Workbooks(nmb).Worksheets(ndx).QueryTables(1).CommandText
ActiveCell.Value = WkshtQryFld.......................

View 2 Replies View Related

Password Protect A Macro

Oct 24, 2007

I currently have a macro which i run by selecting tools, macro, macro and then selecting the one i want and pressing run. if i press run I want a box to appear asking me to input a password and if password matches then run that specific macro, can this be done

View 2 Replies View Related

Password Protect Macro

Oct 22, 2008

Is there a way to password protect the macro code, so that someone can't open the coding?

View 4 Replies View Related

Password Protect Added To Macro

Sep 10, 2009

I have recorded the following macro and wish to add unprotect (with password), run the macro - which formats the worksheet and then password protect all cells with the exception of range E15:H413 which I want to leave editable by users.

View 9 Replies View Related

Password Protect Macro From Running

Dec 5, 2006

i want to make a macro available just for me with help of a password, so that the other users can't run this spesific macro without this password.

View 5 Replies View Related

Password Protect Macro From Running ..

Jan 31, 2008

I need my people to run all kinds of macros, but I want to password protect one of them.

View 6 Replies View Related

Password Protect Multiple Sheets With Macro

Jul 12, 2013

I have a spreadsheet with over a hundred tabs, each of which need to be password protected (same password).

I found code on CFO.com that got me half way there. It protects all the spreadsheets, but it does not password protect the macro itself, meaning that anybody can step into the macro and unlock everything at the click of a button.

The code looks like this.

VB:
Sub ProtectAllSheets()
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="secret123"
Next ws
MsgBox "All Worksheets Protected"

[Code] ....

What can I do to prevent people from stepping into the macro, or prompt a password to actually use the macro itself?

View 1 Replies View Related

Macro To Write Protect A Worksheet With A Password

Dec 10, 2006

I'm trying to protect a worksheet with a password using macro.

View 9 Replies View Related

Automatically Unprotect Worksheet Before Email Macro Then Protect After Email Is Sent

Mar 2, 2009

I currently have a button then when pressed automatically sends a summary report taken from the first page of Sheet 1.

Worksheet needs to be protected all the time, but Macro only works on an unprotected worksheet.

I was wondering what additional code and where to put in so that when
protected back again after Macro has been executed?

Here’s the Macro taken from [url]

View 11 Replies View Related

Toggle "Protect/Unprotect Sheet" In Macro

Nov 27, 2009

Toggle "Protect/Unprotect sheet" in macro
Correct the following macro. It does not work.

View 2 Replies View Related

Password Protect Columns - Hide And Protect Ability To Unhide

Jan 17, 2013

Some sensitive data is held on worksheets that are used by people that do not have access to see the data.

It would be most convenient to keep the data in these worksheets but hide it from view of the users.

Is there a way to password protect a users ability to unhide a column?

View 2 Replies View Related

Macro To Unprotect Sheet - Paste Then Protect Sheet

Apr 8, 2014

I want a sheet to copy and paste into another worksheet, I have that code and its working fine, but what I also want to do is for the sheet to be protected,so the code would be, copy, unlock, paste, lock, save.

Here is the code I have so far. I know i have to include ActiveSheet.Unprotect "passowrd" ActiveSheet.Protect "password", but I dont know where to include that last part of the code.

View 5 Replies View Related

Protect / Unprotect Sheet

Jan 23, 2013

I am using the following code to protect/unprotect a sheet in a tool that i am working on, which seems to work great. It unprotects the sheet runs the code inbetween the two liens of code and then protects the sheet again.

VB:
ActiveSheet.Unprotect Password = "mypassword"
ActiveSheet.Protect Password = "mypassword"

The issue I am having is if i want to go in and edit the sheet without running the code it will not let me. When I go in and type the password to unprotect it says it is invalid. I have typed it exactly how the code reads. I have even tried including the quotes but no luck.

View 4 Replies View Related

Protect - Unprotect The Sheet

Jan 2, 2009

I have a worksheet where the users need to enter time. I have a macro that captures the time when the user hits Ctrl + t

What I want now is a code which protects the cell after entering the time with Ctrl + t.

I tried to do it, but my macro only works when I don't set any passwords to protect the sheet. How can I pass the password to the code and protect the sheet after the code to capture the time is being executed.

View 14 Replies View Related

Protect Or Unprotect Sheet By Various Users?

Jun 22, 2014

Is there is any way we can protect sheet in such a way that; if user - Mr. A inputs his password he can only go and is able to input his data in sheet 1.

I've a file which have multiple sheets say about 80 tabs are present. My colleague only works on one of the tab (sheet) enters data, that file is placed on our general sharing folder I want to know if it is possible that I can assign protection in such a way that when she enters her password she is able to input data only on the sheet in which she works and cannot roam around to other sheets?

Or is it possible that on first sheet there is username or password can appear? And if the data inputting person opens that file and enter her password option appear which can take her to that particular sheet? And if a guest open that file he/she can only view particular sheets which contain reports?

View 1 Replies View Related

Unprotect A Workbook With VBA And Re-protect It When Saved

May 13, 2008

I want the excel spreadsheet to "BE Protected" in standard form, and only be "Unprotected" when macros are enabled -- BUT DONT JUMP TO CONCLUSIONS, hear me out, it gets deeper than that

If the user does not enable macros, I want the book to be protected. If they do enable macros, it becomes unprotected.... (On load is good enough, no need to be real-time)..... But, they can save the book, so it would no longer be protected , which is where my question comes in ...

I could use the -unprotect "password"- on load when macros are enabled but this will only work if the spreadsheet was originally protected and is never saved again. This is a problem because this workbook will be given to others and will be saved time and time again.

So, I had a vision :-) .... function 'before save' , protect the sheet using -protect "password"- , allow the sheet to save, and then unprotect back using 'unprotect "password"' so you can continue using - BUT, the problem with this is now I have created an endless loop in theory, because after it unprotects it would want to re-save again because it changed

View 12 Replies View Related

Protect / Unprotect Worksheet Before VBA Runs

Oct 26, 2011

I have a file that needs to be locked down so that the end user does not have the ability to enter data where they shouldn't. The end users are very Excel illiterate, and have proven that I need to have high security in place. Here is my current VBA code - the purpose of which is to hide/unhide rows depending on data entries. (Disclaimer: this code may not be pretty as I am a VBA rookie, and I've begged borrowed and stolen from about 10 other threads on this board to get where I am, and yes it works).

Code:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "C7" Then Call Changeto1
If Not Intersect(Range("c9"), Target) Is Nothing Then
Rows("15:44").EntireRow.Hidden = True
Rows("15:" & Range("c9").Value + 14).EntireRow.Hidden = False
End If

[Code]...

The question is now....how can I unprotect the sheet so that this code works without allowing them to enter data where they shouldn't. I've been at this for days already.

View 7 Replies View Related

Protect And Unprotect Workbook Using VBA Code

Oct 31, 2011

i'm looking for a vba code to solve the following problem a .xlsm workbook, the protect workbook passwork is known as "111111", the VBA project password is "222222", and how to write vba code to insert a new sheet, suppose the workbook has three worksheet, now using vba code to unprotect workbook, and auto insert a newsheet, then protect workbook again, whcih the password remains as "111111" using a commondbutton to do this, everytime you click, insert a new sheet.

View 9 Replies View Related

How To Protect / Unprotect Multiple Sheets

Jan 27, 2012

I have a workbook where I password protect each sheet. Is there any way to quickly unprotect all sheets, make changes then protect all sheets. I cannot seem to do this by grouping multiple sheets. the option to unpropect/protect is not available.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved