L
Legacy 103420
Guest
As can be seen below I need to change font size depending on length of text.
I'm complete newbie about VBA macros. I ask for learning also. How to write codes to set
if the length of cell is 0-49 set font size 26
if the length of cell is 50-99 set font size 22
if the length of cell is 100-149 set font size 16
if the length of cell is 150-199 set font size 11
if the length of cell is 200-299 set font size 10
if the length of cell is 300-400 set font size 9
2nd question: I set the values manually. Is there a more intelligent macro idea for fitting text in cell using change fonts size by keeping cell dimensions same?
[TABLE="class: grid, width: 774"]
<tbody>[TR]
[TD="align: center"]text[/TD]
[TD="align: center"]length[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet[/TD]
[TD]26[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.[/TD]
[TD]124[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco[/TD]
[TD]183[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.[/TD]
[TD]233[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.[/TD]
[TD]335[/TD]
[/TR]
</tbody>[/TABLE]
I'm complete newbie about VBA macros. I ask for learning also. How to write codes to set
if the length of cell is 0-49 set font size 26
if the length of cell is 50-99 set font size 22
if the length of cell is 100-149 set font size 16
if the length of cell is 150-199 set font size 11
if the length of cell is 200-299 set font size 10
if the length of cell is 300-400 set font size 9
2nd question: I set the values manually. Is there a more intelligent macro idea for fitting text in cell using change fonts size by keeping cell dimensions same?
[TABLE="class: grid, width: 774"]
<tbody>[TR]
[TD="align: center"]text[/TD]
[TD="align: center"]length[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet[/TD]
[TD]26[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit[/TD]
[TD]56[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.[/TD]
[TD]124[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco[/TD]
[TD]183[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.[/TD]
[TD]233[/TD]
[/TR]
[TR]
[TD]Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.[/TD]
[TD]335[/TD]
[/TR]
</tbody>[/TABLE]
Last edited by a moderator: