ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reformatting of cells on requery of sql source (https://www.excelbanter.com/excel-programming/292254-reformatting-cells-requery-sql-source.html)

needhelp

Reformatting of cells on requery of sql source
 
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.

Jake Marx[_3_]

Reformatting of cells on requery of sql source
 
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]


needhelp wrote:
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.




All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com