如何调整使用vba excel中的macros的合并单元格的行高?

我做了一个Excel表格,作为问卷。 为了允许广泛的回答和调整devise,我已经合并了单元格。 我现在遇到的问题是行高不会自动调整。 因此我写了一个简短的macros来解决这个问题。 但是,此macros只适用于单个单元格,并不适用于合并的单元格。 所以,我想知道我该如何解决这个问题。 如何调整使用vba excel中的macros的合并单元格的行高?

感谢您的帮助!

像往常一样,如果你发布你的macros,这将是有帮助的,但我猜你正在尝试使用.entirerow.autofit命令? 如果是这样,我不相信这个函数评估一个合并的单元格。 (有人纠正我,如果我错了!)

您可能要考虑使用“中心范围”而不是合并单元格。 或者你可能想创build一个规则循环通过单元格来检查字符长度,或者是否input了“input密钥” CHR(10) ,以及基于此的大小。 例:

  Sub TestEachCl() Dim CL As Range 'Make sure to include the intersect with usedrange, 'otherwise this will take much longer than necessary. For Each CL In Intersect(Rows(20), ActiveSheet.UsedRange).Cells If InStr(1, CL.Formula, Chr(10)) > 0 Then 'enter key exists in a cell CL.EntireRow.Height = 30 'probably want to close the loop or have it not do 'anything else once it has reached max height, 'so it doesn't reduce the size End If Next CL End Sub