Re: Wrap Text in Merged Cell

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Norman,
Thank you for the URL's.
Of course, after i posted i found some helpful ones too.
One post was also from Greg Wilson, which i modified to my needs. See below.
Now that i see that this works so great i would like to have a second range
(G:H40) included and have not been successful doing so. Would you have a hint?

Thank you,
Stefan

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RowHt As Single, MergeWidth As Single
Dim C As Range, AutoFitRng As Range
Dim CWidth As Single, NewRowHt As Single
Static OldRng As Range
On Error Resume Next
If OldRng Is Nothing Then _
Set OldRng = Range("C22").MergeArea
Set AutoFitRng = Range("C22:H22")
If Not Intersect(OldRng, AutoFitRng) Is Nothing Then
Application.ScreenUpdating = False
With OldRng
RowHt = .RowHeight
CWidth = .Cells(1).ColumnWidth
For Each C In OldRng
MergeWidth = C.ColumnWidth + MergeWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergeWidth
.EntireRow.AutoFit
NewRowHt = .RowHeight
.Cells(1).ColumnWidth = CWidth
.MergeCells = True
.RowHeight = NewRowHt
End With
Application.ScreenUpdating = True
End If
Set OldRng = Target
End Sub


Norman Jones wrote:
>Hi Stefan,
>
>See the following post from Jim Rech (last post in the thread):
>
> http://tinyurl.com/738dd
>
>Also see the following post from Greg Wilson (Post 2):
>
> http://tinyurl.com/cqhwl
>
>---
>Regards,
>Norman


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200507/1
.


Quantcast