allow merging cells in protected sheet

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).
 
D

Doug

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top