ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Does protecting a workbook shut off VBA code? (https://www.excelbanter.com/excel-worksheet-functions/88127-does-protecting-workbook-shut-off-vba-code.html)

Stilla

Does protecting a workbook shut off VBA code?
 
At this site, you guys helped me out on some code to automatically name tabs
from an entry on the worksheets. Works great, thanks!

When I protect the workbook, however, the code does not work. Did I do
something wrong, or does this normaly happen?

I have to protect the workbook for various reasons. Actually, that is why I
needed the tabs to be named automatically.

Any insights welcome!

David D

Does protecting a workbook shut off VBA code?
 
When you protect a worksheet/workbook, even VBA becomes limited.

For example, if a sheet is protected and you use VBA to add a row, you'll
get a runtime error.

You need to add code to your VBA routine that will unprotect the sheet, do
its thing, and then protect it again.

Sheets("whateverthename").UnProtect
....
Sheets("whateverthename").Protect

Hope that helps.

--
-David D


"Stilla" wrote:

At this site, you guys helped me out on some code to automatically name tabs
from an entry on the worksheets. Works great, thanks!

When I protect the workbook, however, the code does not work. Did I do
something wrong, or does this normaly happen?

I have to protect the workbook for various reasons. Actually, that is why I
needed the tabs to be named automatically.

Any insights welcome!



All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com