Re: Wrap Text in Merged Cell
- From: "stefan via OfficeKB.com" <forum@xxxxxxxxxxxx>
- Date: Sun, 10 Jul 2005 02:33:15 GMT
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
.
- Follow-Ups:
- Re: Wrap Text in Merged Cell
- From: Norman Jones
- Re: Wrap Text in Merged Cell
- References:
- Wrap Text in Merged Cell
- From: stefan via OfficeKB.com
- Re: Wrap Text in Merged Cell
- From: Norman Jones
- Wrap Text in Merged Cell
- Prev by Date: Re: is there anyone that has successfully sent a page or a copied range using outlook express?
- Next by Date: Re: is there anyone that has successfully sent a page or a copied range using outlook express?
- Previous by thread: Re: Wrap Text in Merged Cell
- Next by thread: Re: Wrap Text in Merged Cell
- Index(es):