Solved

MS Excel preserving column widths upon data refresh

Posted on 2014-01-03
3
526 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 7

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now