Excel Macro Autorun

WaelTalaat

New Member
Joined
Feb 19, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi, I have a Macro code to enable the row grouping as below and i saved it as enable macro excel
but unfortunately when i re-open the excel file the file showed as protected and to unprotect only the grouping i have to re-run the macro manually
so do you have any idea how to keep the macro running after reopen to protect the cells and keep only the grouping row worked
the code i used is :

Sub allowGroup()
Dim mySheet As Worksheet
Set mySheet = Application.ActiveSheet
Dim myPW As String
myPW = Application.InputBox("Type one Password to protect your worksheet:", "allowGroup", "", Type:=2)
mySheet.Protect Password:=myPW, Userinterfaceonly:=True
mySheet.EnableOutlining = True
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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