Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 995
  • Last Modified:

MS Excel preserving column widths upon data refresh

The workbook connection properties, usage, refresh control are set to Enable background refresh and refresh data when opening the file.

The worksheet is formatted to fit on a single page when printed. However whenever the data is refreshed I lose my desired column widths.

How can I preserve column widths upon data refresh?
0
Lee Ingalls
Asked:
Lee Ingalls
1 Solution
 
etech0Commented:
Try this:

in excel, press Alt-F11. This will open the VB editor. On the left side, double click on Sheet1 (or the name of your sheet in question)

Paste this code into the white code editor:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Columns.AutoFit
End Sub

Open in new window


It will do Autofit again every time things change.
0
 
NBVCCommented:
If you go to Data tab, then Properties (from the Connections section).  There will be a checkbox called Adjust Column Width.  Make sure it is not checked.
0
 
Lee IngallsDirector of IT/TS, Quality and FinanceAuthor Commented:
Ok, I feel foolish for that one. Thanks NBVC!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now