Learn Excel 2010 - "Wrap Cells and Resize": Podcast #1472

If you like this content, please consider visiting the video on YouTube and subscribe to the MrExcel Channel to show your support!
This video has been published on Nov 17, 2011.
Herbie has a Calendar spreadsheet being populated by a huge concatination formula. He asks if there is a way to combine Wrap Cells and Shrink to Fit as he works in the calendar. In Episode #1472 Bill shows us one way to accomplish this.

...This blog is the video podcast companion to the book, Learn Excel 2007 through Excel 2010 from MrExcel. Download a new two minute video every workday to learn one of the 512 Excel Mysteries Solved! and 35% More Tips than the previous edition of Bill's book!

"The Learn Excel from MrExcel Podcast Series"

MrExcel.com — Your One Stop for Excel Tips and Solutions. Visit us today!
maxresdefault.jpg


Transcript of the video:
MrExcel podcast is sponsored by Easy-XL.
Learn Excel from MrExcel podcast, episode 1472: wrap cells and shrink to fit.
Hey, welcome back to MrExcel netcast.
I'm Bill Jelen.
Today's question is sent in by Herbie.
Herbie has a calendar and the calendar is being populated by these huge concatenation formulas.
The height and width of each cell is fixed; you can't change it.
He wants them to be consistent throughout, but he would like to turn on both wrap text and shrink to fit.
Unfortunately, that is not something we do.
We do control one.
You see, the shrink to fit is available, but as soon as your turn on wrap text, it is grayed out.
He says, “What I would like is, you know, the length of the entries is anywhere from 3 to 120 characters and I'd like the text to get smaller as it gets longer,” but he says, “When it's just three, I don't want it to be 72 point.
I don't want it to be, you know, completely insane, you know.
Is there some way to do that?” Well, yes, we can do that with VBA.
So, I’m going to switch over here, Alt F11, and I’m going to find--there is podcast 1472, go to the sheet that has the calendar and double-click that sheet.
Now, this is a special place for event handler macros.
So, we're going to choose worksheet from the left and then from the right, we're going to choose calculate.
So every time one of those formulas calculates this little bit of code-- I’m just going to run.
I've already written the code.
I’m going to paste it in.
We will talk about what it's doing here, let’s get rid of the extra-- Okay, so, I've already hardcoded that the calendar is in B4 to H11.
You can't see H11, but trust me it goes down to that.
We're going to look at each cell in that range and then use the LEN function, the length function, to figure out how many characters are in the result of that formula at this point in time.
If it's less than 30, I’m just going to leave it at 11, but as we get longer and longer and longer and longer, I keep making the font size smaller.
All right, so, let's come back here and we will calculate this.
First of all, let’s see if it's-- if it's working.
All right, so, here I can see that it's not quite right.
It's not quite working in the way that I want it to work.
So, maybe we need to make the size smaller.
We’ll kind of go 9 7 5 4 or something like that and you'll really just kind of have to do-- do some testing.
There we go.
So, now, it's all fitting in that cell and as we add more descriptions to the places where this is pulling from, then it automatically gets smaller.
Now, it requires some tweaking.
It's not as good as just turning on wrap text, but if you think about it, you know, in 15 minutes of testing this text and seeing how it looks at that size, you should come up with something pretty clever.
So, that’s automatically going to 7 point and this one here, which is shorter, stays at eleven point.
Again, is that underlying cells down here change?
Let's just come down here and we'll type something really, really, really long.
We go back up.
Hopefully, that cell would have-- yes, it automatically got smaller in response to the fact that the worksheet calculated, which happened in response to the fact that I changed one of those underlying cells.
So, kind of cool little away-- although that's probably too small, but again, some tweaks here and Herbie would be good to go.
Combining wrap text with a different VBA shrink to fit.
Great question.
I want to thank Herbie for sending that question in and I want to thank you for stopping by.
We'll see you next time for another netcast from MrExcel.
 

Forum statistics

Threads
1,221,783
Messages
6,161,913
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top