Using Macros in Excel and protecting selecting cells

Copper Contributor

I have a user that has developed a spreadsheet that is used company-wide to aid in organizing and pricing potential projects for our clients. The spreadsheet includes a lot of formulas, conditional formatting, and grouped rows. The grouping of rows will allow users to pick and choose which sections of the spreadsheet will be needed for pricing.

 

The issue I have is that I want to protect the cells that contain formulas so no one will be able to change or override them. But once the cells are protected, the grouping function does not work. I found a macro that allows for cell protection and will let me group and ungroup rows; however, it is only for a one-time use. My question is, how can I protect cells but also permanently allow for grouping and ungrouping? The spreadsheet needs to be used by many people.

 

Here's the macro used: 

Sub allowGroup()

Dim mySheet As Worksheet

Set mySheet = Application.ActiveSheet

Dim myPW As String

myPW = Application.InputBox("Type one Password to protect your worksheet:", "allowGroup", "", Type:=2)

mySheet.Protect Password:=myPW, Userinterfaceonly:=True

mySheet.EnableOutlining = True

End Sub

 

If you have any suggestion on this macro can be tweaked or changed to allow many users to use while protecting cell, I would greatly appreciate it.

 

Thank you for your help!  

0 Replies