AdjustColumnWidth Property

Microsoft Excel Visual Basic

AdjustColumnWidth Property

       

True if the column widths are automatically adjusted for the best fit each time you refresh a query table. False if the column widths aren’t automatically adjusted with each refresh. The default value is True. Read/write Boolean.

Remarks

The maximum column width is two-thirds the width of the screen.

Example

This example turns off automatic column-width adjustment for the newly added query table on the first worksheet in the first workbook.

With Workbooks(1).Worksheets(1).QueryTables _
    .Add(Connection:= varDBConnStr, _
        Destination:=Range("B1"), _
        Sql:="Select Price From CurrentStocks " & _
            "Where Symbol = 'MSFT'")
    .AdjustColumnWidth = False
    .Refresh
End With