Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default The text length versus the cell size...

Jim,

I was working on something similar today. This doesn't measure in pixels
but it would not be hard to convert:

Put the text in a cell in a column with no other contents. Use the command
"Columns(x).AutoFit" and then get the width of the column using
"Columns(x).ColumnWidth". Then change the font of the cell 1 point at a
time until you get the desired width. For more precision you could put the
string into the test cell multiple times (eg, if the string is "xyz", put in
the cell: "xyzxyzxyzxyz") and then divide the resulting column width by the
multiple used, but keep in mind that Excel (97, at least) only allows a
column width up to 255.

HTH,
Shockley

"Jim Carlock" wrote in message
...
If I want to automatically adjust the font size property for a
cell, how would I do that? I want to make the font go down
1 point at a time, compare the pixel length of the text to a
cell's pixel width.

--
Jim Carlock
http://www.microcosmotalk.com
Feel free to post back to the newsgroup!





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default The text length versus the cell size...

I've given up on it at the moment. Some other things became a
priority.

Thanks for your comments about the AutoFit, Shockley.

--
Jim Carlock
http://www.microcosmotalk.com
Feel free to post back to the newsgroup!


"shockley" wrote in message
...
Jim,

I was working on something similar today. This doesn't measure in pixels
but it would not be hard to convert:

Put the text in a cell in a column with no other contents. Use the

command
"Columns(x).AutoFit" and then get the width of the column using
"Columns(x).ColumnWidth". Then change the font of the cell 1 point at a
time until you get the desired width. For more precision you could put

the
string into the test cell multiple times (eg, if the string is "xyz", put

in
the cell: "xyzxyzxyzxyz") and then divide the resulting column width by

the
multiple used, but keep in mind that Excel (97, at least) only allows a
column width up to 255.

HTH,
Shockley

"Jim Carlock" wrote in message
...
If I want to automatically adjust the font size property for a
cell, how would I do that? I want to make the font go down
1 point at a time, compare the pixel length of the text to a
cell's pixel width.

--
Jim Carlock
http://www.microcosmotalk.com
Feel free to post back to the newsgroup!







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default The text length versus the cell size...

Jim, glad to help. A quick and easy solution would be to enable the
ShrinkToFit property of the cell.
In Excel, with a cell or range selected, it would be Format | Cells |
Alignment | ShrinkToFit
In vba it would be Cells(x,y).ShrinkToFit = True
Shockley


"Jim Carlock" wrote in message
...
I've given up on it at the moment. Some other things became a
priority.

Thanks for your comments about the AutoFit, Shockley.

--
Jim Carlock
http://www.microcosmotalk.com
Feel free to post back to the newsgroup!


"shockley" wrote in message
...
Jim,

I was working on something similar today. This doesn't measure in

pixels
but it would not be hard to convert:

Put the text in a cell in a column with no other contents. Use the

command
"Columns(x).AutoFit" and then get the width of the column using
"Columns(x).ColumnWidth". Then change the font of the cell 1 point at a
time until you get the desired width. For more precision you could put

the
string into the test cell multiple times (eg, if the string is "xyz",

put
in
the cell: "xyzxyzxyzxyz") and then divide the resulting column width by

the
multiple used, but keep in mind that Excel (97, at least) only allows a
column width up to 255.

HTH,
Shockley

"Jim Carlock" wrote in message
...
If I want to automatically adjust the font size property for a
cell, how would I do that? I want to make the font go down
1 point at a time, compare the pixel length of the text to a
cell's pixel width.

--
Jim Carlock
http://www.microcosmotalk.com
Feel free to post back to the newsgroup!









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell text length conditional formatting - Excel 2003 Manc Shaun Excel Discussion (Misc queries) 3 March 26th 09 11:58 AM
Summing a column based on the length of text in a cell in anothercolumn [email protected] Excel Worksheet Functions 13 November 26th 08 05:42 PM
Cell size? Or size limit for Text data type? CClem Excel Discussion (Misc queries) 0 April 21st 06 04:09 PM
How do I set up a text cell in Excel with restricted length? ElonRoger Excel Discussion (Misc queries) 2 September 28th 05 04:39 PM
Macro or Function to make text size to suite text Length? lbbss Excel Discussion (Misc queries) 4 December 14th 04 07:53 PM


All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"