Row Height AutoFit doesn't work
excel, vba
Solution
Make sure that the cells that have line breaks in them have "Wrap Text" turned on. You can turn it on with VBA like so:
Sub test1()
Dim a As String, b As String
a = "Please"
b = "Do AutoFit"
Range("A1").Value = a & vbNewLine & b
Range("A1").WrapText = True
Range("A1").EntireRow.AutoFit
End Sub
Problem
So, today is my bad day I discovered that excel row AutoFit - doesn't work ``` a = "Please" b = "Do AutoFit" range01.Value = a & vbNewLine & b range01.EntireRow.AutoFit // First and last line are horizontally cutted ``` Chr(10) instead of vbNewLine - doesn't help It works only if I write without line breaks: ``` range01.value = a & b range01.EntireRow.AutoFit // works !!! Thanks to Microsoft ! ```