How to Allow Row Changes in a Protected Excel Table Without Unlocking Formulas
Question details
Users need a way to insert or delete rows in a protected Excel worksheet table without compromising the security of locked formula columns.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing an employee database or performance table where end-users must be able to add or remove records, but calculation formulas must remain locked to prevent accidental changes.
- Observed behavior
- By default, protecting a sheet to lock formulas also disables the ability to add or delete rows within a structured table, restricting necessary data entry.
Ensure you have the Developer tab enabled in your ribbon to access VBA features, and it is highly recommended to test the macro on a backup copy of your workbook before applying it to live data.
Use a VBA Macro to Handle Row Insertions and Deletions
Automate the process of temporarily unprotecting the sheet, adding or removing a row, and immediately re-protecting the sheet.
This method uses a macro to bypass the default worksheet protection limitations. By assigning this script to a clickable button, users can easily manage table rows while your complex formulas remain completely secure from manual edits.
Press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.
Click on 'Insert' in the top menu and select 'Module' to create a blank script window.
Write or paste a VBA script that unprotects the active sheet (e.g., ActiveSheet.Unprotect Password:="YourPassword"), performs the row insertion (Selection.EntireRow.Insert), and then reprotects the sheet (ActiveSheet.Protect Password:="YourPassword").
Go back to your worksheet, insert a shape or form control button, right-click it, and select 'Assign Macro' to link your new script to the button.
Navigate to File > Save As, and choose 'Excel Macro-Enabled Workbook (*.xlsm)' from the format dropdown to ensure your VBA code is preserved.

Manage Protected Tables and VBA Macros Seamlessly in WPS Spreadsheet
WPS Spreadsheet offers robust support for protecting worksheets and running VBA macros, allowing you to secure your formulas while maintaining flexibility for data entry.
- 1. Open your Workbook: Launch WPS Spreadsheet and open your macro-enabled workbook.
- 2. Access Developer Tools: Navigate to the 'Developer' tab. If it is hidden, enable it by going to Menu > Options > Customize Ribbon.
- 3. Manage Sheet Protection: Use the 'Review' tab for built-in 'Protect Sheet' features, or open the VBA editor to automate the unprotect/protect cycle just as you would traditionally.

Frequently Asked Questions
Why does Excel grey out the 'Insert Row' option when a sheet is protected?
When you protect a worksheet, Excel locks the structure and cells by default to prevent unauthorized changes. Even if you allow users to 'Insert rows' in the protection dialog, structured tables (ListObjects) restrict row insertion if any columns (like your formulas) within the table are locked.
Can I allow row deletion in a protected sheet without VBA?
Standard worksheet protection allows you to check 'Delete rows' when setting up the password. However, if the row intersects with a locked cell (such as your formula columns), Excel will still block the deletion. VBA is the most reliable workaround for this specific limitation.
Will this VBA method expose my protection password?
If you hardcode the password into the VBA script, anyone who can view the VBA code can see the password. To prevent this, you should lock the VBA project itself with a separate password under Tools > VBAProject Properties > Protection in the VBA editor.
How do I prevent users from deleting the wrong rows using the macro?
You can enhance your VBA script to include a confirmation prompt (using MsgBox) before executing the deletion, or restrict the macro's execution so it only deletes rows if the active cell falls within a specific named range or table boundary.




