Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel+courses - macros

Forum home » Delegate support and help forum » Microsoft Excel Training and help » excel+courses - Macros

excel+courses - Macros

ResolvedVersion Standard

peter has attended:
Excel Advanced course

Macros

can single macro apply to all worksheets of a workbook without activating for each worksheet. i.e. activate once for entire workbook

RE: macros

Hi Peter,

Thanks for your question. I have asked my colleague who does VBA to address this question, and will get back to you.

Rehards

Richard

RE: macros

Hi Peter

Try using this peice of VBA in a new module of the VBA editor.
It will set the password to 123, which you can change by simply editing the code below.

You can add your own macro buttons to your excel toolbar, and assign each macro.

I have also attached the example sheet so you can see it in action.

Regards

Richard

------------
Option Explicit
Sub Protectsheets()
Dim wsheet As Worksheet

For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Protect password:="123"

Next wsheet

End Sub


Sub unprotectsheet()
Dim wsheet As Worksheet
Dim password As String
password = InputBox("Please enter the password")

For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Unprotect password:=password

-------

Attached files...

protectallsheets.xls

 

Training courses

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Separate the year from a date

To separate the year from a date use the =year() function, eg a date is in cell A1 and in A2 you wish to display the year enter the function =year(A1)

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.