首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VBA如何用合并的单元格自动调整行高?

VBA如何用合并的单元格自动调整行高?
EN

Stack Overflow用户
提问于 2018-10-27 09:36:55
回答 1查看 4.7K关注 0票数 0

我有一个动态数据没有设置在数据高度。如何在数据高度中设置动态高度。

代码语言:javascript
复制
sub test()
    Sheets(1).Cells(2, 16).Value = "Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal."
End sub

单元数据全数据显示现在我如何使用"WrapText“和"AutoFit”,但全数据显示单元,但更多的话,在隐藏在单元格中。行高409如何增加单元格高度。

给我样本链接和输出。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-27 11:30:44

不要使用合并单元格和自动匹配,只使用换行文本,并将列宽设置为任何在数据上看起来不错的列宽。

代码语言:javascript
复制
Sub test()

    Dim row_num
    Dim col_num

    row_num = 2
    col_num = 16

    Columns(col_num).ColumnWidth = 65

    Sheets(1).Cells(row_num, col_num).Value = "Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working  normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal.Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same.To convert graphic display.After transfer to HMI and test operation finished." _
    & "Test system with process is working normal. Process inform HMI finish oil fiber display not show we check found HMI damage after we check no have spare after we move HMI alarm display at control spinning to install. But the type of HMI not same. To convert graphic display.After transfer to HMI and test operation finished. Test system with process is working normal."

    Sheets(1).Cells(row_num, col_num).WrapText = True

End Sub

编辑版

您可以检查以下代码的自动装配合并单元格。

列A到C的单元格宽度设置为12,对于高度,占文本长度45%的比率取决于这个宽度,如果要更改宽度,也必须更改比率。

代码语言:javascript
复制
Sub test1()


    Sheets(1).Cells(2, 1).Value = " Testing Testing TestingTestingTesting Testing Testing TestingTestingTesting Testing TestingTesting Testing Testing TestingTesting Testing Testing Testing TestingTesting Testing TestingTesting Testing Testing Testing Testing Testing Testing Testing TestingTestingTesting Testing"
    Range("A2:C2").Merge
    Range("A2:C2").WrapText = True

    Columns("A:C").ColumnWidth = 12

    text_length = Len(Sheets(1).Cells(2, 1).Value)
    Rows("2:2").RowHeight = text_length * 0.45


End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53020567

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档