Auto Resize Text

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
Is there a way using VBA to make the text in a box, consisting of merged cells, auto fit the box?

Example:

The user enters a small amount of text in this large area of merged cells and runs AutoResizeText script. The script should resize the text to lets say a maximum of font size 16.

On the flip side, the user enters a large amount of text into the same area of merged cells but this time the text does not fit into the merged cell area. When the user runs the AutoResizeText script it should resize the text to lets say a minimum of font size 8 .

Does anyone think this can be done?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
It can be done

but its clunky

you will need to calculate first the maximum number of characters in the text string that will fit at whatever is the std font, then code to change the font accordingly based on the number of characters entered

LEN(A1) will return total string length
then

if LEN < whatever then range.font.size=whatever

or something similar
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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