Export (0) Print
Expand All
19 out of 28 rated this helpful - Rate this topic

AutoFit Method [Excel 2003 VBA Language Reference]

Office 2003

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.AutoFit
		


Applies to | Range Collection



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.