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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,713
Messages
6,174,043
Members
452,542
Latest member
Bricklin

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