所以今天是我的坏日子
我发现excel行自动调整-不起作用
a = "Please"
b = "Do AutoFit"
range01.Value = a & vbNewLine & b
range01.EntireRow.AutoFit // First and last line are horizontally cutted
Chr(10)而不是vbNewLine-没有帮助
仅当我写没有换行符时,它才有效:
range01.value = a & b
range01.EntireRow.AutoFit // works !!! Thanks to Microsoft !
最佳答案
确保其中包含换行符的单元格已打开“自动换行”。您可以使用VBA将其打开,如下所示:
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