ChrisDotNisbet
New Member
- Joined
- Feb 19, 2020
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi there,
I'll preface this by saying I do not know how to read VBA, nor do I have any experience writing VBA
I have a question surrounding protecting cells within a sheet that has a macro built in to insert a new row.
I know how to protect cells, and the macro that exists has been inherited from another sheet.
When the cells are protected, the macro will not run, due to the protection.
Below is the current code:
Sub New_Pricing_Line()
Range("ac1000").End(xlUp).Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(2, 0).Range("A1:ac1").Select
Selection.Copy
ActiveCell.Offset(-2, 0).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
My question is, how can I protect the required cells, yet enable the above code to work?
I appreciate that I have not stated the cells I need to protect, however if anyone can show me where in the code I can input the cell range, to enable the protection and input the new row.
If you need an image of sheet in question, I am happy to upload it.
Thanks for the help,
Chris
I'll preface this by saying I do not know how to read VBA, nor do I have any experience writing VBA
I have a question surrounding protecting cells within a sheet that has a macro built in to insert a new row.
I know how to protect cells, and the macro that exists has been inherited from another sheet.
When the cells are protected, the macro will not run, due to the protection.
Below is the current code:
Sub New_Pricing_Line()
Range("ac1000").End(xlUp).Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(2, 0).Range("A1:ac1").Select
Selection.Copy
ActiveCell.Offset(-2, 0).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
My question is, how can I protect the required cells, yet enable the above code to work?
I appreciate that I have not stated the cells I need to protect, however if anyone can show me where in the code I can input the cell range, to enable the protection and input the new row.
If you need an image of sheet in question, I am happy to upload it.
Thanks for the help,
Chris