AutoFit Row Size with Merged Cells

R

RyanH

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
 
J

Joel

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
 
R

RyanH

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top