I have protected excel sheet. The first row is at no.10 and all new rows are inserted below.
I have put below code with command button to insert a new row at the bottom with same format and formula copied from above row. This works perfectly fine.
ActiveSheet.Unprotect""
ActiveSheet.Range("A10").CurrentRegion.Offset(ActiveSheet.Range("A10").CurrentRegion.Rows.Count - 1).Resize(2).EntireRow.FillDown
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowDeletingRows:=True, AllowSorting:=True _
, AllowFiltering:=True
ActiveSheet.Protect "", True, True
But I cannot insert a new row in the middle of rows(with same format and formulas copied from above row).
Can someone please edit my code so that I can insert a new row anywhere in the middle of rows wherever I want to insert by highlighting with mouse click.
Of course the new row should be created below the highlighted cell and copied with same format and formulas as above row.
Sub AddRow()
ActiveSheet.Unprotect "1234"
ActiveCell.Offset(1).EntireRow.Insert
ActiveCell.Offset(1).EntireRow.Cells.Locked = False
ActiveSheet.Protect "1234"
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.