nplanek
asked on
Excel Top and Bottom Cell Padding
I'm trying to add cell padding on the top and bottom of all cells in an Excel 2007 worksheet. I found a solution on Experts Exchange from Akoster, but it doesn't run for me:
Range([...]).EntireRow.Aut oFit
Range([...]).RowHeight = Range([...]).RowHeight + 12
Range([...]).VerticalAlign ment = xlCenter
The error is...Run-time error '1004'
Method 'Range' of object' _Global' failed.
What should I change?
Range([...]).EntireRow.Aut
Range([...]).RowHeight = Range([...]).RowHeight + 12
Range([...]).VerticalAlign
The error is...Run-time error '1004'
Method 'Range' of object' _Global' failed.
What should I change?
Sorry missed one reference there:
Sub PadRows()
Dim rngPad As Range
Set rngPad = Application.Range("A1:A34")
With rngPad
.EntireRow.AutoFit
.RowHeight = .RowHeight + 12
.VerticalAlignment = xlCenter
End With
End Sub
The A1:A34 could be any range that includes all the rows you want.
ASKER
I have cells that have one, two or three lines. The code seems to center the text vertically, because I can see the text in the one and two line cells move; I see no difference in the three line cell (it shows no padding). Ideally I would like the text aligned at the bottom of the cell with padding at the top and bottom. Possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can work with this....thanks!
Thanks for the points. Can you just say why you did not award an A here? The grading guidelines http://www.experts-exchang e.com/help /viewHelpP age.jsp?he lpPageID=2 6 say you should award an A unless the answer is deficient in some way. If it is I'd be happy to help you.
ASKER
I'm sure your solution was the best available, but didn't meet my needs perfectly. I just needed the text aligned at the bottom, with padding on the top and bottom.
Open in new window
Or better,Open in new window