Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Change column width according to specific cell content

Hi everyone,

Is there any way by which i be able to know the width of the contents
of a cell. I need to change column width of a column according to the
width of the contents. Autofit would work but according to the longest
content in the column. I need the column width to be set according to
the width of a specific cell content. Thank you in advance. BYE

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Change column width according to specific cell content

Dear RosH,

The Help section of VBA gives you the answer (see below). You can specify a
specific cell range that you may auto fit!

AutoFit Method
See Also Applies To Example Specifics
Changes the width of the columns in the range or the height of the rows in
the range to achieve the best fit.

expression.AutoFit

expression Required. An expression that returns a Range object. Must be a
row or a range of rows, or a column or a range of columns. Otherwise, this
method generates an error.

Remarks
One unit of column width is equal to the width of one character in the
Normal style.

Example
This example changes the width of columns A through I on Sheet1 to achieve
the best fit.

Worksheets("Sheet1").Columns("A:I").AutoFit
This example changes the width of columns A through E on Sheet1 to achieve
the best fit, based only on the contents of cells A1:E1.

Worksheets("Sheet1").Range("A1:E1").Columns.AutoFi t

Regards,
Jan Bart
Excelerate


"RosH" wrote:

Hi everyone,

Is there any way by which i be able to know the width of the contents
of a cell. I need to change column width of a column according to the
width of the contents. Autofit would work but according to the longest
content in the column. I need the column width to be set according to
the width of a specific cell content. Thank you in advance. BYE


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Change column width according to specific cell content

copy the content of the cell to an empty column. autofit that column. Get
the column width from that column. Clear/resize that column. Set the
column in question to that width.

--
Regards,
Tom Ogilvy

"RosH" wrote in message
ups.com...
Hi everyone,

Is there any way by which i be able to know the width of the contents
of a cell. I need to change column width of a column according to the
width of the contents. Autofit would work but according to the longest
content in the column. I need the column width to be set according to
the width of a specific cell content. Thank you in advance. BYE



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
Change Cell Width WITHOUT changing Column width dww701 Excel Discussion (Misc queries) 1 January 12th 09 10:52 PM
How do I change the column width in only one cell at a time? Cathi Excel Discussion (Misc queries) 4 June 13th 07 09:15 PM
change the width of a specific cell Andrew Excel Worksheet Functions 3 October 14th 06 12:19 AM
Change the width of a column by using a cell reference None Specified Excel Worksheet Functions 0 April 3rd 06 09:54 PM
How do I change the width a specific cell w/o changing whole page THBCFLO Excel Discussion (Misc queries) 3 February 7th 06 11:01 PM


All times are GMT +1. The time now is 04:58 PM.

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

About Us

"It's about Microsoft Excel"