Referencing macro in add-in or from another sheet

BoilerBob

Board Regular
Joined
Apr 10, 2006
Messages
98
Thanks to various posts on the board, I have the following code that will protect all sheets in my workbook: :biggrin:
------------------------------------------------------------------------------------
Sub ProtectAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect DrawingObjects:=True, AllowInsertingRows _
:=True, AllowFiltering:=True, Password:="password"
ActiveSheet.EnableSelection = xlNoRestrictions
Next ws
End Sub
-------------------------------------------------------------------------------------

I would like to use the above via add-in or personal.xls so that when I open a new workbook, I can protect all the sheets in the new workbook without copying and pasting the module into every new workbook.

When I put in personal.xls, I can run the macro but it only works on the personal.xls workbook.

When I load as an add-in, I do not 'see' the macro to reference it. I think this is the way to go, but need insights on how to work with add-ins.

Thanks...
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi

You can leave it in your personal.xls but change

thisworkbook.worksheets

to

activeworkbook.worksheets


Tony
 
Upvote 0
Danka, Gracias, Thanks, and well done mate... Worked great.

I will continue with my education on add-ins...
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

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