Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 1.79 KB

Excel.QueryTable.AdjustColumnWidth.md

File metadata and controls

55 lines (34 loc) · 1.79 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
QueryTable.AdjustColumnWidth property (Excel)
vbaxl10.chm518112
vbaxl10.chm518112
Excel.QueryTable.AdjustColumnWidth
2901cc84-92d2-7021-2360-9c31dc1153b3
05/03/2019
medium

QueryTable.AdjustColumnWidth property (Excel)

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

Syntax

expression.AdjustColumnWidth

expression A variable that represents a QueryTable object.

Remarks

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

If you import data by using the user interface, data from a web query or a text query is imported as a QueryTable object, while all other external data is imported as a ListObject object.

If you import data by using the object model, data from a web query or a text query must be imported as a QueryTable, while all other external data can be imported as either a ListObject or a QueryTable.

Use the QueryTable property of the ListObject to access the AdjustColumnWidth property.

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

[!includeSupport and feedback]