Vba help password

stebrownsword

Board Regular
Joined
Apr 16, 2010
Messages
151
Hi Guys,

the following macro, changes a few cells etc, then protects the sheet.... however I wanted the protected sheet part to have a password "Sausage"...

could you guys ammend my macro, so it protects the sheet with a password as "Sausage"

Sub RATIFY1()
'
' RATIFY1 Macro
'
'
Sheets("Outline Generator").Select
ActiveSheet.Unprotect
Range("E6").Select
ActiveCell.FormulaR1C1 = "Outline Ratified"
Cells.Select
Selection.Locked = True
Selection.FormulaHidden = True
Range("B8").Select
Sheets("Outline Generator").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False
End Sub





Thanks in advance
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Code:
Sub RATIFY1()

    With Worksheets("Outline Generator")
    
        .Unprotect
        .Range("E6").FormulaR1C1 = "Outline Ratified"
        With .Cells
    
            .Locked = True
            .FormulaHidden = True
        End With
    
        .Range("B8").Select
    
        .Protect Password:="Sausage", DrawingObjects:=False, _
                 Contents:=True, Scenarios:=False
    End With
End Sub

You might need to change the Unprotect to Unprotect "Sausage" for subsequent runs of the macro.
 
Upvote 0
Adjust the activesheet to include the password.

HTML:
   ActiveSheet.Protect Password:="Sausage", DrawingObjects:=False, Contents:=True, Scenarios:= _
False
 
Upvote 0
Hi Just realised, it keeps opening the document where i created the macro.... but I don't want it to open the document where I created the macro... i just want the macro to work on the document which i have open?

help please?
 
Upvote 0
The you need to place the macro in the Personal Workbook if you want to apply the protection on any workbook you have open.

The personal workbook is normally hidden. If you are using 2003 then look at the View Menu and see if you can unhide, if not then look to record a new macro and select to store the macro in the Personal workbook then stop recording you can then unhide.

If using 2007 or 2010 look to do the same but you would look under the View Tab.

Hope this helps you out.
 
Upvote 0

Forum statistics

Threads
1,203,473
Messages
6,055,616
Members
444,803
Latest member
retrorocket129

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