ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoFit Row Height with Merged Cells in the Row (https://www.excelbanter.com/excel-programming/407930-autofit-row-height-merged-cells-row.html)

RyanH

AutoFit Row Height with Merged Cells in the Row
 
I need to add text from a Userform Textbox to a worksheet. Sometimes the
textbox may conatin a few sentences. Unfortunately, the text needs to span
across 3 Columns. 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



All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com