LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default unlocking merge cells

Hi all

I found a code to use on merged-cells to auto-change the row height
after updating the cell content. I changed the code a little but now I
found a problem that I can not solve, maybe someone can help me out.
The problem is: After updating the row-heigt the (unlocked) merged-
cells are getting locked, so they can't be changed when the sheet is
protected. I don't want the cells to be locked, the cells are not in a
specific range.

The code I use is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single, OldRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range, test As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
OldRwHt = c.RowHeight
Set ma = c.MergeArea

For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True

If NewRwHt OldRwHt Then
ma.RowHeight = NewRwHt
Else
ma.RowHeight = OldRwHt
End If

cWdth = 0: MrgeWdth = 0: OldRwHt = 0
Application.ScreenUpdating = True

End If
End With
End Sub

Please, can someone help me out.

gr.

Maurice
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unlocking cells maltagirl Excel Discussion (Misc queries) 3 June 16th 08 07:20 PM
Unlocking protected cells Vanilla Skies Excel Worksheet Functions 0 September 26th 06 04:04 AM
Unlocking cells Vanilla Skies Excel Worksheet Functions 1 September 25th 06 04:30 AM
Unlocking Cells Sisilla Excel Programming 1 July 18th 03 08:58 PM
Unlocking Cells Tom Ogilvy Excel Programming 0 July 18th 03 08:46 PM


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"