Friday, 15 February 2019

How to increase row height in Excel by X. ie. Add vertical cell padding


I have this report and I want to increase the vertical cell padding to make it easier to read.


Now, typically you could just select multiple rows and change the row height until you're satisfied.


However, in this case, I have cells with wrapped text and multiple lines. I can't change change the the row height, because the wrapped text will get cut off.


What I want to do is increase the row height of a bunch of cells by a certain value. Rather than just change it to a specify value. ie.


rowheight = rowheight + X

Not


rowheight = X


Can you do this in excel? Will I need VBA?



Answer



I'd go for the code below... not sure if there would be a way to apply it for all rows once. I'd be glad (and upvote) if someone else here knows :)


Sub fixRowHeight()

Dim oRange As Excel.Range
Dim oRow As Excel.Range
Dim dblFactor As Double

Set oRange = Sheets(1).Range("A1:B25")
dblFactor = 5

For Each oRow In oRange.Rows

oRow.RowHeight = oRow.RowHeight + dblFactor

Next oRow

End Sub

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...