Question:
Microsoft Excel Question?
2011-06-15 21:48:37 UTC
Before I left work today, I was asked by one of the secretaries if I could help her with her excel program tomorrow. I said sure, that I could help her figure out the solution to her problem.

Her problem is that, on her excel spreadsheet, she can't format the cells so that it shows all of the information. In the first column, the names are short, but she wants it so that it shows all the information in other columns that might have to be wordy and lengthy to describe the short name. Is there a way to format it to show all of the information in the cells and not hide it?
Three answers:
Karl B
2011-06-15 23:38:52 UTC
simple solution - no macro needed (but it is not automatic):



Click on the box to the left of the A column header and above the 1 row header (this should select all the columns in the worksheet).



Then mouse-over the edge between the A and B column headers (should show resizing mouse pointer) and double-click to autofit all selected columns.



You may have to also play with the "Wrap Text" attribute to get the effect you want if it still doesn't look the way you want it to.



Best wishes..
garbo7441
2011-06-16 06:01:20 UTC
Edit: to do this 'automatically', after the initial autofit, for 'future' column widths that are exceeded will require a macro.



You are referring to autofitting the columns. To do this automatically will require a macro.



Copy the following macro to the clipboard:





Sub Autofit_Columns()

Dim ws As Worksheet

For Each ws In Worksheets

ws.Select

For Each col In ActiveSheet.UsedRange.Columns

col.AutoFit

Next

Next

End Sub



Press ALT + F11



In the menus at the top of the VBE, select INSERT > MODULE



Paste the macro into the editing area to the right.



Still in the VBE, go to Tools > Macros, select the macro, and click 'RUN'.



If there is the possibility that data added later might also exceed column widths, after performing the above process, do the following.



Copy this event handler to the clipboard:



Private Sub Workbook_SheetChange(ByVal Sh As Object, _

ByVal Target As Range)

ActiveSheet.Range(Target.Address). EntireColumn.AutoFit

End Sub



Press ALT + F11



Double click 'THIS WORKBOOK' in the Microsoft Excel Objects in the upper left quadrant.



Paste the code into the editing area to the right.



Close the VBE and return to the worksheet. Save the workbook.



Now, if data entered exceeds column width, autofit will be applied to the column when the user tabs to the next cell.



The one possible downside to autofitting is that if you have columns with very little data, the column width will be reduced to fit the data. That makes for some very narrow columns from time to time.
i_love_jon
2011-06-16 04:50:29 UTC
At the top or the side (Letter or Number of Row or Column) you just need to stretch that out.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...