Created
April 9, 2020 00:20
-
-
Save mjdescy/53fc4f3a9bfc694c55dfb99684fcbc50 to your computer and use it in GitHub Desktop.
Adjust Row Height in Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Const DefaultRowHeight As Double = 14.5 | |
Public Sub IncreaseRowHeightByOneLine() | |
Call SafelyAdjustRowHeightForAllRowsInRange(Range:=Selection, RowHeightAdjustment:=DefaultRowHeight) | |
End Sub | |
Public Sub DecreaseRowHeightByOneLine() | |
Call SafelyAdjustRowHeightForAllRowsInRange(Range:=Selection, RowHeightAdjustment:=-DefaultRowHeight) | |
End Sub | |
Private Sub SafelyAdjustRowHeightForAllRowsInRange(ByRef Range As Excel.Range, ByVal RowHeightAdjustment As Double) | |
Dim Row As Excel.Range | |
For Each Row In Range.Rows | |
Call SafelyAdjustRowHeight(Range:=Row, RowHeightAdjustment:=RowHeightAdjustment) | |
Next Row | |
End Sub | |
Private Sub SafelyAdjustRowHeight(ByRef Range As Excel.Range, ByVal RowHeightAdjustment As Double) | |
Dim NewRowHeight As Double | |
NewRowHeight = Range.RowHeight + RowHeightAdjustment | |
If NewRowHeight <= 0 Then | |
Exit Sub | |
End If | |
Range.RowHeight = NewRowHeight | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment