Reformatting of cells on requery of sql source

N

needhelp

Is there any way to prevent excel from reformatting the cell widths when the data is refreshed from the datasource. I have a worksheet that automatically refreshes when it is opened, but it reformats all of the column headers to fit the longest piece of data for that column.
 
J

Jake Marx

Hi needhelp,

You can set the AdjustColumnWidth property of the QueryTable to False, which
tells Excel not to update column widths on each refresh of the QueryTable.
I think you need to do this only once, so you could execute the following
statement from the Immediate Window in the VBE:

Sheets("Sheet1").QueryTables(1).AdjustColumnWidth=False

Then save your workbook...next time you open, the column widths should not
be adjusted.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Top