Autosize merged cells
- From: Teri <Teri@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 10:42:02 -0800
I have a merged cell that should auto-size as users enter data. I understand
that VBA code is necessary and I have even attempted to use the following
which doesn't seem to work:
Private Sub Worksheet_Change(ByVal Target As Range)
End Sub
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range
With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
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
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub
Can anyone help please?
.
- Follow-Ups:
- Re: Autosize merged cells
- From: Gord Dibben
- Re: Autosize merged cells
- Prev by Date: Re: Data Validation "List" - Setting length of list shown
- Next by Date: Re: Paste Special Help (Excel 2003)
- Previous by thread: Re: See where cell is referenced in other sheets
- Next by thread: Re: Autosize merged cells
- Index(es):