Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
cell text length conditional formatting - Excel 2003 | Excel Discussion (Misc queries) | |||
Summing a column based on the length of text in a cell in anothercolumn | Excel Worksheet Functions | |||
Cell size? Or size limit for Text data type? | Excel Discussion (Misc queries) | |||
How do I set up a text cell in Excel with restricted length? | Excel Discussion (Misc queries) | |||
Macro or Function to make text size to suite text Length? | Excel Discussion (Misc queries) |