Allow Ungrouping VBA

Copper Contributor

Hi

 

I am trying to allow ungrouping in a protected worksheet however when saving and reopening the workbook and click to ungroup it is saying that i cannot do this on a locked worksheet. All the codes i have tried don't work.  

1 Reply

@matt1770

Unprotect the sheet at the beginning of the macro, then protect it again at the end. For example:

 

Sub MyUngroup()
    ActiveSheet.Unprotect Password:="secret"
    ' Your code to ungroup data
    ...
    ActiveSheet.Protect Password:="secret"
End Sub

 

Replace secret with the password that you used to protect the worksheet. If you didn't specify a password, use "" or omit the Password:=... part.