ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Autofit - But At Least a Certain Height (https://www.excelbanter.com/excel-discussion-misc-queries/207529-autofit-but-least-certain-height.html)

Susan

Autofit - But At Least a Certain Height
 
In my spreadsheet, I have my row height set at 40 because that way everything
displays nicely when I print it out on letterhead (landscape). Is there a
way for me to adjust my cell height to make sure I have a height of at least
40, but allow it to adjust automatically for longer entries?

Dave Peterson

Autofit - But At Least a Certain Height
 
You could use a macro that does the autofit and then compares the results to
40. If it's smaller, then it'll resize the rowheight.

Option Explicit
Sub testme01()
With Worksheets("Sheet1")
.Rows(1).AutoFit
If .Rows(1).RowHeight < 40 Then
.Rows(1).RowHeight = 40
End If
End With
End Sub


If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Susan wrote:

In my spreadsheet, I have my row height set at 40 because that way everything
displays nicely when I print it out on letterhead (landscape). Is there a
way for me to adjust my cell height to make sure I have a height of at least
40, but allow it to adjust automatically for longer entries?


--

Dave Peterson

Susan

Autofit - But At Least a Certain Height
 
Dave:

When I tried to run that macro, I received the following error:

Run time error "9"
Subscript out of range

Any suggestions? Thank you.

"Susan" wrote:

In my spreadsheet, I have my row height set at 40 because that way everything
displays nicely when I print it out on letterhead (landscape). Is there a
way for me to adjust my cell height to make sure I have a height of at least
40, but allow it to adjust automatically for longer entries?


Susan

Autofit - But At Least a Certain Height
 
NEVERMIND DAVE IT WORKED!!!!! Thank you so much for your help.

"Susan" wrote:

In my spreadsheet, I have my row height set at 40 because that way everything
displays nicely when I print it out on letterhead (landscape). Is there a
way for me to adjust my cell height to make sure I have a height of at least
40, but allow it to adjust automatically for longer entries?



All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com