VBA script help needed to unlock a sheet to add a new line then protect again

Vansar

New Member
Joined
May 7, 2019
Messages
3
Hello there,

I have a 47 (AA - AU) column table which has 8 Formulae which i need to protect from overwriting, however the table needs to have the ability to add new rows on a daily basis,
I have used data validation to protect the cells, but much to my amusement you can still copy and paste over the Validation, i have looked at protecting the sheet but then i cannot add rows??

Is there a VBA Script to create a button to Un-protect the sheet, add new row then apply the protection again, it would need to be password protected

The columns which need protecting are L,Q,R,AA,AI,AJ,AK,AL

Any help or assistance would be greatly appreciated

Many thanks

Craig
 

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.
Hello there,

I have a 47 (AA - AU) column table which has 8 Formulae which i need to protect from overwriting, however the table needs to have the ability to add new rows on a daily basis,
I have used data validation to protect the cells, but much to my amusement you can still copy and paste over the Validation, i have looked at protecting the sheet but then i cannot add rows??

Is there a VBA Script to create a button to Un-protect the sheet, add new row then apply the protection again, it would need to be password protected

The columns which need protecting are L,Q,R,AA,AI,AJ,AK,AL

Any help or assistance would be greatly appreciated

Many thanks

Craig

Put the following macro in a button, it works in the following way:
- Select a cell.
- Press the button.
- The macro unprotects, inserts a row above the selected row, protects the sheet again.

Code:
Sub Macro1()
    ActiveSheet.Unprotect "abc"
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    ActiveSheet.Protect "abc", DrawingObjects:=False, Contents:=True, _
        Scenarios:=False, AllowFormattingCells:=True, _
        AllowFormattingColumns:=True, AllowFormattingRows:=True, _
        AllowInsertingColumns:=True, AllowInsertingRows:=True, _
        AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
        AllowDeletingRows:=True, AllowSorting:=True, _
        AllowFiltering:=True, AllowUsingPivotTables:=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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