allow merging cells in protected sheet

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

When I protect the sheet, the Merge & Center button is greyed out. I need to
allow users to merge and center cells in a protected sheet (these cells are
not locked).
 
Thanks, Rob

With my limited VB knowledge and some searching, I put in this macro and it
unprotects the sheet, merges the selected cells, and then re-protects the
sheet with the formatting I need. Works for me.

Sub MergeCells()
'
' MergeCells Macro
' merge selected cells but preserve formatting ability for unlocked cells
'
' Keyboard Shortcut: Ctrl+m
'
'
Const myPassword = "password"

ActiveSheet.Unprotect myPassword
Selection.Cells.Merge
ActiveSheet.Protect myPassword, DrawingObjects:=False, Contents:=True,
Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingRows:=True,
AllowDeletingRows:= _
True, AllowSorting:=True

End Sub
 
Back
Top