• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1145
  • 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?
Lee Ingalls
Lee Ingalls
1 Solution
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)
End Sub

Open in new window

It will do Autofit again every time things change.
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.
Lee IngallsDirector of IT/TS, Quality and FinanceAuthor Commented:
Ok, I feel foolish for that one. Thanks NBVC!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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