I see that I can use range.AutoFit to set the column width to be the best fit for the contents. I need this capability for row height instead.
I'm accepting user comments as part of a macro. The macro selects some cells, merges them, then puts in the comment. From MSO developer ref in Excel, it looks like setting the cell property for "wrapText" to true that it is supposed to adjust the row height automatically. I have not found this to be the case.
"Microsoft Excel will change the row height of the range, if necessary, to accommodate the text in the range."
I found a formula here in the forums that someone was using to adjust the row height using With range:
Does anyone know of a simpler method for setting the row height to be just enough to fully display the wrapped cell contents?Code:.RowHeight = .Font.Size * (Len(xlWksht.Range("A" & ii + 1).text) - Len("Comments:")) / w + rht + (rht - .Font.Size)
Thanks for the great help!
~ Aaron





Reply With Quote