Range.AutoFit Method

Changes the width of the columns in the range or the height of the rows in the range to achieve the best fit.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function AutoFit As Object
'Usage
Dim instance As Range
Dim returnValue As Object

returnValue = instance.AutoFit()
Object AutoFit()

Return Value

Type: System.Object

Remarks

The expression must be a row or a range of rows, or a column or a range of columns. Otherwise, this method generates an error.

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

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace