ColumnWidth Property

Microsoft Office Web Components Visual Basic

Returns or sets the width of all columns in the specified range. Returns Null if the columns in the range are not all the same width. Use the IsNull function to determine whether the return value is Null. Read/write Variant.

expression.ColumnWidth

expression    Required. An expression that returns a Range object.

Example

This example sets the formula, column width, and number format for all the cells in the range A1:F10 on the active worksheet.

Sub Format_Sheet1()
    Dim rngCurrent
    
    Set rngCurrent = Spreadsheet1.ActiveSheet.Range("A1:F10")
    
    rngCurrent.Formula = "=rand()"
    
    rngCurrent.ColumnWidth = 10
    
    rngCurrent.NumberFormat = "#.###"
End Sub