我正在使用下面的代碼設定Row Height of Range為不小于 45。這行代碼有效, Rng.EntireRow.RowHeight = 45
但如果我將它與 IF 條件一起使用,則完全沒有效果。我試圖用 ROWS 替換 EntireRow ,但也沒有效果。
Sub Row_Height()
Dim Rng As Range
Set Rng = ActiveSheet.Range("A3", Cells(Rows.count, "A").End(xlUp))
If Rng.EntireRow.RowHeight < 45 Then
Rng.EntireRow.RowHeight = 45
End If
End Sub
uj5u.com熱心網友回復:
Rng 不是單個單元格,因此其中的行都可以具有不同的高度。
而是遍歷其中的行,以便您可以一一檢查高度。
Sub Row_Height()
Dim r As Range
Dim Rng As Range
Set Rng = ActiveSheet.Range("A3", Cells(Rows.Count, "A").End(xlUp))
For Each r In Rng.Rows
If r.RowHeight < 45 Then r.RowHeight = 45
Next
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/341093.html
