Solved

MS Excel preserving column widths upon data refresh

Posted on 2014-01-03
3
587 Views
Last Modified: 2014-01-03
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
Comment
Question by:Lee Ingalls
3 Comments
 
LVL 10

Expert Comment

by:etech0
ID: 39753996
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
 
LVL 23

Accepted Solution

by:
NBVC earned 500 total points
ID: 39754000
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
 
LVL 8

Author Closing Comment

by:Lee Ingalls
ID: 39754016
Ok, I feel foolish for that one. Thanks NBVC!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question