Stop Excel Row Height Self-Adjust on Refresh

The Situation
I have a Microsoft Excel 2007 file that connects to a SQL Server 2008 R2 database. The Excel file pulls data using lookup tables and displays the data in an Excel Spreadsheet.

The Problem
We can select all cells and set row height to be 30 for example, but everytime we refresh the data in the Excel spreadsheet, all the rows get re-adjusted to fit the data and lose that consistency.

A Workaround: New line inserted before and after
So this is where I am at the moment without VBCode and other suggestions. Instead I add a newline in front of and after the smallest data value (one that I know will never be two lines (or two words)) within the SQL query itself. We have a DEPT column that is an acronym of the departments so for example:
copyraw
SELECT 
	Date, 
	Reservation, 
	Contact, 
	JobTitle, 
	Dept 
FROM 
	my_imaginary_table 
WHERE 
	Contact='Joe'
  1.  SELECT 
  2.      Date, 
  3.      Reservation, 
  4.      Contact, 
  5.      JobTitle, 
  6.      Dept 
  7.  FROM 
  8.      my_imaginary_table 
  9.  WHERE 
  10.      Contact='Joe' 
Would become
copyraw
SELECT 
	Date, 
	Reservation, 
	Contact, 
	JobTitle, 
	CHAR(10) + Dept + CHAR(10) AS Dept
FROM 
	my_imaginary_table 
WHERE 
	Contact='Joe'
  1.  SELECT 
  2.      Date, 
  3.      Reservation, 
  4.      Contact, 
  5.      JobTitle, 
  6.      CHAR(10) + Dept + CHAR(10) AS Dept 
  7.  FROM 
  8.      my_imaginary_table 
  9.  WHERE 
  10.      Contact='Joe' 
Now when Excel refreshes the data, it acknowledges new lines (the "CHAR(10)" as with other cell data). Quite a lot of spacing (the height of one text line), but our customers were complaining it became too convoluted and cramped when refreshing data and preferred the end result with this change.

Note on "row height":
We did not want the customer having to format the report after they've already gone through the hassle of clicking on the big fat refresh button... Keeping It Simple Silly. So the suggestion of selecting all cells and then right-clicking and selecting "row height" is beyond us. We have since simplified this so that only the person who knows how to hit the refresh button is the one to save as a PDF file and sends it to all customers. Training these people in adjusting row height would be like a magician revealing the secrets to his tricks... no it wasn't really, time was the issue.

Additional conditions
Direct access to our databases, both development and production, means that anyone with access to the Excel spreadsheet can go and view the connections and see the username/password details (granted read-only access). One of the requirements was that only authorised personnel could refresh the data on the Excel spreadsheet and they would then save as PDF and send to appropriate staff.

Other Issues
I usually felt that CHAR(13) goes hand in hand with CHAR(10) and although it displayed and printed properly, when saving as a PDF, CHAR(13) would return weird question mark symbols instead.

Bonus
All rows with this would be about 3 lines of text in height. Data with 4 lines of text would adjust their row to fit but all others were left untouched. Perfect!

Other Searches that I may search for again but get me nothing
  • stop row height change on refresh data excel 2007
  • excel row height refresh data
  • row height being reset on refresh
  • excel disable readjusting row height on data refresh
Category: Excel :: Article: 391

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.