PC Review


Reply
Thread Tools Rate Thread

AutoFit Row Size with Merged Cells

 
 
RyanH
Guest
Posts: n/a
 
      14th Mar 2008
I need to add text from a Userform Textbox to a worksheet. Sometimes the
textbox may conatin a few sentences. I would like my code to put the textbox
text into the merged cells, wrap the text to fit, and automatically adjust
the row height.
Is it possible to do this or is there an easier way? The text has to be
contained between Col.C and Col.E.

Sub AutoFitText()

With ActiveCell 'ActiveCell = Range("B10") in this case

'.....I have additional code here

.Offset(30, 1).Value = " • Comments: " & tbxComments

With Range(.Offset(30, 1), .Offset(30, 3))
.Merge
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = True
.Rows.EntireRow.AutoFit
End With

'.....I have additional code here as well

End With

Thanks in Advance,
Ryan
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      14th Mar 2008
Sub AutoFitText()
set startcell = activecell
With startcell
.Offset(30, 1).Value = " • Comments: " & tbxComments

With Range(startcell.Offset(30, 1), startcell.Offset(30, 3))
.Merge
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = True
.Rows.EntireRow.AutoFit
End With
End With


"RyanH" wrote:

> I need to add text from a Userform Textbox to a worksheet. Sometimes the
> textbox may conatin a few sentences. I would like my code to put the textbox
> text into the merged cells, wrap the text to fit, and automatically adjust
> the row height.
> Is it possible to do this or is there an easier way? The text has to be
> contained between Col.C and Col.E.
>
> Sub AutoFitText()
>
> With ActiveCell 'ActiveCell = Range("B10") in this case
>
> '.....I have additional code here
>
> .Offset(30, 1).Value = " • Comments: " & tbxComments
>
> With Range(.Offset(30, 1), .Offset(30, 3))
> .Merge
> .HorizontalAlignment = xlLeft
> .VerticalAlignment = xlCenter
> .WrapText = True
> .Rows.EntireRow.AutoFit
> End With
>
> '.....I have additional code here as well
>
> End With
>
> Thanks in Advance,
> Ryan

 
Reply With Quote
 
RyanH
Guest
Posts: n/a
 
      14th Mar 2008
The code works fine but the part that autofits the row height. The row
height seems to remain the same and you can not see the rest of the text
unless you manually adjust the row height.

Is there anyother solutions to automatically adjust the row height?

Thanks Ryan

"Joel" wrote:

> Sub AutoFitText()
> set startcell = activecell
> With startcell
> .Offset(30, 1).Value = " • Comments: " & tbxComments
>
> With Range(startcell.Offset(30, 1), startcell.Offset(30, 3))
> .Merge
> .HorizontalAlignment = xlLeft
> .VerticalAlignment = xlCenter
> .WrapText = True
> .Rows.EntireRow.AutoFit
> End With
> End With
>
>
> "RyanH" wrote:
>
> > I need to add text from a Userform Textbox to a worksheet. Sometimes the
> > textbox may conatin a few sentences. I would like my code to put the textbox
> > text into the merged cells, wrap the text to fit, and automatically adjust
> > the row height.
> > Is it possible to do this or is there an easier way? The text has to be
> > contained between Col.C and Col.E.
> >
> > Sub AutoFitText()
> >
> > With ActiveCell 'ActiveCell = Range("B10") in this case
> >
> > '.....I have additional code here
> >
> > .Offset(30, 1).Value = " • Comments: " & tbxComments
> >
> > With Range(.Offset(30, 1), .Offset(30, 3))
> > .Merge
> > .HorizontalAlignment = xlLeft
> > .VerticalAlignment = xlCenter
> > .WrapText = True
> > .Rows.EntireRow.AutoFit
> > End With
> >
> > '.....I have additional code here as well
> >
> > End With
> >
> > Thanks in Advance,
> > Ryan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofit Merged cell Code is changing the format of my merged cells =?Utf-8?B?SkI=?= Microsoft Excel Misc 0 20th Aug 2007 02:12 PM
Is there a way to Autofit Merged Cells in a row? =?Utf-8?B?SkxTbWl0aA==?= Microsoft Excel Misc 2 1st Aug 2006 04:49 PM
Row Autofit on Merged Cells Jluo Microsoft Excel Misc 1 18th Apr 2005 02:37 PM
Autofit Merged Cells? Can we do this? kenji4861 Microsoft Excel Misc 6 1st Nov 2003 12:56 AM
Autofit Row & Merged Cells Alex Burman Microsoft Excel Discussion 1 9th Oct 2003 02:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.