Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

define groups in excel

Status
Not open for further replies.

maximas

Programmer
Nov 29, 2002
40
US
I have a worksheet, but I want only parts of the worksheet be able to add or delete rows. for example:
A B C D E
1
2
3
4 protected from adding or deleting this row
5 protected from adding or deleting this row
6 protected from adding or deleting this row
7
8

How could I do that!
 
Select everything but the rows you want to protect and right-click/follow the format drop menu to format cells. Go to the Protection tab and unlock all cells you want to be excepted from Protection. Now go to Tools, Protection, Protect Sheet. This should do it foro you.
 
This will work if your spreadsheet if it is not protected, but my sheet is protect. Here is the macro to add and delete a line, but I want to make sure that the selection where they want to insert is not in the protected range. here is the code:

ActiveSheet.Unprotect Password:="test"
ActiveWorkbook.Sheets("worksheet").Select
Set currentcell = ActiveSheet.Range("1:13")
Do While ActiveCell.Select <> currentcell
If ActiveCell.EntireRow.Select = True Then
Selection.Copy
ActiveCell.Insert (xlDown)
Application.CutCopyMode = False
ActiveCell.Select
ActiveCell.Offset(1, 0).value = &quot;&quot;
ActiveCell.Offset(1, 1).value = &quot;&quot;
ActiveCell.Offset(1, 2).value = &quot;&quot;
ActiveCell.Offset(1, 3).value = &quot;&quot;
ActiveCell.Offset(1, 4).value = &quot;&quot;
ActiveCell.Offset(1, 5).value = &quot;&quot;
ActiveCell.Offset(1, 11).value = &quot;&quot;
End If
Loop
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:=&quot;test&quot;
 
I knew it couldn't be a simple as it looked.
I'm afraid I can't offer anything further...out of my range.
I'm sure one of the others will have the solution for you...
good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top