ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prevent adding rows (https://www.excelbanter.com/excel-programming/297524-prevent-adding-rows.html)

Rene[_3_]

Prevent adding rows
 
In VB, how do I prevent users from adding/deleting
columns and rows? I can't protect the sheet, because the
users sometimes have to adjust column widths, formats,
etc.
I played around with "AllowDeletingRows = False" but
couldn't figure it out.

Thanks!

Dana DeLouis[_3_]

Prevent adding rows
 
Try unlocking the cells first. Then allow your users to do everything but
Insert/Delete.
HTH.

Sub Macro()
ActiveSheet.Unprotect
Cells.Locked = False
ActiveSheet.Protect _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingHyperlinks:=True, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowUsingPivotTables:=True, _
_
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False
End Sub


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Rene" wrote in message
...
In VB, how do I prevent users from adding/deleting
columns and rows? I can't protect the sheet, because the
users sometimes have to adjust column widths, formats,
etc.
I played around with "AllowDeletingRows = False" but
couldn't figure it out.

Thanks!





All times are GMT +1. The time now is 08:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com