If worksheet protected then unprotect else run rest to code?

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,782
Office Version
  1. 2016
Platform
  1. Windows
Is there code to say:

If worksheet protected, unprotect, else move on with code,

but if it is protected to unprotect that sheet run the code and then reprotect it before looping through the other sheets when building a table of contents?

I have several worksheets that are protected and I use a table of contents maker that loops through the sheet and pluts a return to Main Menu in A1.

I merge cells A1 throught E1 to give a bigger area to click for the Main Menu words.

I have unlock the cells in rows 1 and 2, but the sheets that are protected keep causing me problems..
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,128
Messages
5,857,531
Members
431,884
Latest member
Gcmoore63

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
Top