Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default AutoFit Row Size with Merged Cells

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default AutoFit Row Size with Merged Cells

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default AutoFit Row Size with Merged Cells

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
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
AutoFit - Merged Cells David A. Excel Programming 0 September 25th 07 09:44 PM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
Autofit on Merged Cells. [email protected] Excel Programming 5 June 1st 06 09:45 PM
Row Autofit on Merged Cells Jluo Excel Discussion (Misc queries) 1 April 18th 05 02:37 PM
Autofit in Merged Cells? Mick Excel Discussion (Misc queries) 4 February 14th 05 05:15 PM


All times are GMT +1. The time now is 02:59 AM.

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

About Us

"It's about Microsoft Excel"