Forum Discussion
AKoag
Mar 01, 2022Copper Contributor
How can I set Row Height above autofit by .5 pixels?
I'm trying to set row height for several rows which have different heights by an increase of .5 pixels higher than autofit, is there a way to do this?
HansVogelaar
Mar 01, 2022MVP
Row height increments by 1 pixel, so there is no point in incrementing it by 0.5 pixels.
Here is code to increment row height by 1 pixel after AutoFit:
Sub AutoFitPlus(rng As Range)
Dim rw As Range
Application.ScreenUpdating = False
rng.EntireRow.AutoFit
For Each rw In rng.Rows
rw.RowHeight = rw.RowHeight + 1 / ActiveWindow.PointsToScreenPixelsX(1)
Next rw
Application.ScreenUpdating = True
End Sub
Sub AutoFitPlusSelection()
AutoFitPlus Selection
End Sub
Select a range, then run AutoFitPlusSelection.