Is there a way to autofit the row height to whatever a number is in that row without VBA? e.g. if cell b14 has the numeral "40" in it, can I autofit row be to 40 without VBA?. I am using Excel 365.
Is there a way to autofit the row height to whatever a number is in that row without VBA? e.g. if cell b14 has the numeral "40" in it, can I autofit row be to 40 without VBA?. I am using Excel 365.
Fraid not. It will have to be done manually, or with code.
Got it but disappointed. Thanks for that.
Might you know the code to do that and, if so, does that code need to be on every sheet or the ThisWorkbook Object?
Any specific reason why you want a certain row height for a certain row?
That depends on exactly what you want to do. Please attach a sample workbook and describe:
Which cells you want this to apply to?
What action will trigger the resize of the row height. That is, do you want to push a button? Have it happen automatically when a number is added, or changes?
Here's a quick example. Type a number into any cell in column A. That row will be set to have a height of that number in points.
Sorry Jeff. I downloaded your row height.xlsm and entered 13 in A3 and 100 in A4. Nothing happened. I attached, I think, a screen shot of the worksheet after I entered the numbers.
Attachment 863844
Also, my problem is that if we got your example to work for me, I don't know how to get the number to be entered that I want. Let's say the row in question has a cell with 3 rows in one cell with wrapped text meaning no line breaks, just Excel wrapping the text onto two additional rows of text in the cell. If an Excel formula or VBA could tell me there were 3 rows, I could get the row height for the font I wanted, say 15.6, and add say, 7 to that meaning it would set the row height to print what looks like 3-1/2 rows of text. That way the last row in my cell would never get cropped off in printing.
Your attachment was not valid. To attach an image, first click Go Advanced under your edit box. Then click in the text to set the cursor to where you want the image to appear, then press the image icon and attach your image.
It sounds like you are not permitting macros to run. Here is a screen video of me showing the same file: https://youtu.be/OgkwAjyNoic
It would save trouble to state your requirements up front. I answered your question, but you didn't really ask for what you need.I don't know how to get the number to be entered that I want
Automatically setting row height based on the amount of text in a cell that has wrapped text is tricky because it depends on the attributes of the specific font that you are using. Also most fonts are proportional fonts, so you can't just count the number of characters, and there is no way for Excel to tell you where it is wrapping the lines. The necessary cell height will vary depending on the font, character size, and the specific text that is in the cell.
I think I answered a question like this some years ago, and there are some things you can do but none of them are great. I'll get back you if I can dig it up.
Here are some examples of the same text in different fonts. The second column gives row height. This doesn't take into account fonts of different sizes, or different text.
row height.jpg
There are two problems with auto sizing cell heights:
1. After auto sizing an additional blank line may appear in the cell.
2. after auto sizing, the text in the cell is fully visible, while on the printout the last line of text may be truncated (in whole or in part).
I once wrote the following macro to remove an unnecessary blank line, but by adding a certain number of points to the height of the shape, the second problem can be solved as well.
I assume that the height of cell B2 should be corrected.ArtikPlease Login or Register to view this content.
Last edited by Artik; 03-24-2024 at 07:37 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks