Where do I add this Macro

P

Pamela

Hi Guys!!!
I got this macro that adds a password to a spreedsheet:
=============
Private Sub Workbook_Open()
'If you have different passwords
'for each Worksheet.
Sheets(1).Protect Password:="Secret", _
UserInterFaceOnly:=True


Sheets(2).Protect Password:="Carrot", _
UserInterFaceOnly:=True


'Repeat as needed.
End Sub
===============

But I don't where to write the macro to make it work.
please help me,
Pamela XoXo
 
P

PCLIVE

Alt+F11 to open the VBEditor. Then double-click "ThisWorkbook". Paste code
in right-hand pane. That should do it.
 
G

Gord Dibben

It is workbook event code.

Right-click on the Excel left of "File" on the menubar or on Excel Icon at
left end of Title bar if your window is not maximized.

Select "View Code" to open Thisworkbook Module.

Paste the code into that module.

Alt + q to return to the Excel window.

Save, close and re-open the workbook.


Gord Dibben MS Excel MVP
 
P

Pamela

It is workbook event code.

Right-click on the Excel left of "File" on the menubar or on Excel Icon at
left end of Title bar if your window is not maximized.

Select "View Code" to open Thisworkbook Module.

Paste the code into that module.

Alt + q to return to the Excel window.

Save, close and re-open the workbook.

Gord Dibben  MS Excel MVP






- Show quoted text -

THANK YOU!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top