Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Column width in Excel 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AnneK - 28 Dec 2007 23:50 GMT
My Bureau Chief has an Excel 2003 document that he receives from our
finacial unit.  When he tries to print the document out it shows ###### in
different cells throughout the entire document.  In the past when he used
Excel 2000 he would just double click on the right hand side of the top of
the column and it would expand the column one character larger and would
print the whole number in each of those cells.  In Excel 2003 when he does
this, it still shows the #####'s and he has to physically go in and move the
column over ever so slightly to get it to print out correctly.  When there
are numerous columns that have this issue, it is very time consuming.  Is
there another way to correct this that is fast and easy rather than manually
having to expand the column?  He also does not want to make all of the
columns the same width as this would take up quite a bit more paper when
printing out.

PS  Throughout each column there are different font sizes.
RagDyer - 29 Dec 2007 00:46 GMT
Select all the columns, then, from the Menu Bar:

<Format> <Columns> <AutoFit>

Each column will be *individually* sized to display the widest entry in that
column.
Signature

HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

> My Bureau Chief has an Excel 2003 document that he receives from our
> finacial unit.  When he tries to print the document out it shows ###### in
[quoted text clipped - 11 lines]
>
> PS  Throughout each column there are different font sizes.
Gord Dibben - 29 Dec 2007 00:51 GMT
Try selecting all the columns in the range and Format>Column>Autofit Selection.

Which is what the double-click should be doing...........fitting to selection,
not expanding one character larger as you state.

Gord Dibben  MS Excel MVP

>My Bureau Chief has an Excel 2003 document that he receives from our
>finacial unit.  When he tries to print the document out it shows ###### in
[quoted text clipped - 11 lines]
>
>PS  Throughout each column there are different font sizes.
Thomas M. - 31 Dec 2007 17:23 GMT
I think that what she meant by "one character larger" is that
double-clicking the column border will expand the column so that it is one
character larger than the longest value in the column.

I work for the same organization as Anne, and while I'm not working this
particular issue I have seen the spreadsheet in question.  RagDyer's
recommendation of selecting multiple columns--and maybe even all columns,
depending on how you want things to look--and then going to Format > Column
> AutoFit Selection may be a viable work-around, but I'd be interested in
knowing the root cause of the behavior.

Double-clicking the column border does indeed auto size the column so that
all the values can be seen.  However, even after double-clicking the column
borders the ####### mask can still be seen in Print Preview for certain
values, and the spreadsheet will print out that way as well.  I think the
deeper question is, "If double-clicking works to expand the columns and make
all the values visible in Normal view, then why aren't those values
displayed properly in Print Preview or on the actual print out?"

--Tom

> Try selecting all the columns in the range and Format>Column>Autofit
> Selection.
[quoted text clipped - 22 lines]
>>
>>PS  Throughout each column there are different font sizes.
Gord Dibben - 31 Dec 2007 22:39 GMT
I think that would be a function of your printer driver and the way it
interfaces with Excel.

That's why Print Preview is such a handy feature.

Gord

> "If double-clicking works to expand the columns and make
>all the values visible in Normal view, then why aren't those values
>displayed properly in Print Preview or on the actual print out?"
Rick Rothstein (MVP - VB) - 01 Jan 2008 03:41 GMT
I've read through this thread and I think you may be able to use this macro.
It lets you specify a "buffer factor" value (a number greater than 1) to
increase a column width by (for example, 1.1 will make a column 10% wider
than the AutoFit width) to create "extra" white space for the text UNLESS
the column width is already the buffer factor or more larger, in which case
that width is preserved. The buffer factor is specified in the Const
statement... I used 10% for my tests; but, perhaps, you can use 1.05 (5%
extra white space)... you will have to test to see what minimum buffer
factor you can get away with.

Sub SizeToFit()
 Dim R As Range
 Dim X As Long, z
 Dim ColWidth As Double
 Const Tolerance As Double = 1.1  '10% extra room
 Set R = Worksheets("Sheet1").UsedRange
 For X = R.Column To R.Columns.Count
   ColWidth = Columns(X).ColumnWidth
   If Worksheets("Sheet1").Cells(Rows.Count, X).End(xlUp).Row = 1 Then
     If Worksheets("Sheet1").Cells(Rows.Count, X).Value = "" Then
       GoTo Continue
     End If
   End If
   Columns(X).AutoFit
   If Tolerance * Columns(X).ColumnWidth < ColWidth Then
     Columns(X).ColumnWidth = ColWidth
   Else
     Columns(X).ColumnWidth = Tolerance * Columns(X).ColumnWidth
   End If
Continue:
 Next
End Sub

Rick

> My Bureau Chief has an Excel 2003 document that he receives from our
> finacial unit.  When he tries to print the document out it shows ###### in
[quoted text clipped - 11 lines]
>
> PS  Throughout each column there are different font sizes.
Thomas M. - 07 Jan 2008 20:16 GMT
Rick,

Thanks for the code!  The first two columns of the spreadsheet are labels
for the rows and we don't want to change the widths of those columns, so I
added an IF statement at the top of the FOR loop as follows:

 For X = R.Column To R.Columns.Count
   If X < 3 Then
       GoTo Continue
   End If

Otherwise, I did not need to change anything.

--Tom

> I've read through this thread and I think you may be able to use this
> macro. It lets you specify a "buffer factor" value (a number greater than
[quoted text clipped - 46 lines]
>>
>> PS  Throughout each column there are different font sizes.
Rick Rothstein (MVP - VB) - 07 Jan 2008 21:12 GMT
You are quite welcome... I'm glad you could make use of the code. By the
way, instead of adding your 3-line If-Then code block, you could have just
changed the For-Next statement to this...

For X = 3 To R.Columns.Count

I wasn't sure where your data was, so I just used the UsedRange as my
limits; but since you know the beginning column is 1, you can simply adjust
the For-Next lower limit to avoid the first 2 columns.

Rick

> Rick,
>
[quoted text clipped - 61 lines]
>>>
>>> PS  Throughout each column there are different font sizes.
Thomas M. - 08 Jan 2008 01:09 GMT
I tried something like that.  Actually, what I did was to define a named
range that started with the 3rd column and covered the entire area of data,
and then I inserted that named range into the code.  Done right, I'm sure
that would also fix the problem, but I'm not real familiar with Excel VBA
these days and so I was having a problem making it loop the correct number
of times.  Clearly, I had a bug in my code, so I finally figured that
switching my approach and using a simple IF statement was easier than
keeping the more complicated code and trying to find the bug.  For whatever
reason, changing the lower limit on the FOR loop didn't occur to me, but it
is a more efficient solution.

Thanks for the help.

> You are quite welcome... I'm glad you could make use of the code. By the
> way, instead of adding your 3-line If-Then code block, you could have just
[quoted text clipped - 73 lines]
>>>>
>>>> PS  Throughout each column there are different font sizes.
aaronroessler@gmail.com - 18 Jan 2008 19:51 GMT
On Dec 31 2007, 9:41 pm, "Rick Rothstein \(MVP - VB\)"
<rickNOSPAMn...@NOSPAMcomcast.net> wrote:
> I've read through this thread and I think you may be able to use this macro.
> It lets you specify a "buffer factor" value (a number greater than 1) to
[quoted text clipped - 46 lines]
>
> > PS  Throughout each column there are different font sizes.

I would love to use this code as well, but i am getting an error. I am
using Excel 2004 on Mac OS X Leopard.  The error i get is on this
line...  Const Tolerance As Double = 1.1  '10% extra room  - Syntax
error?

any ideas?

Thanks in Advance,
Aaron
aaronroessler@gmail.com - 18 Jan 2008 19:57 GMT
On Jan 18, 1:51 pm, aaronroess...@gmail.com wrote:
> On Dec 31 2007, 9:41 pm, "Rick Rothstein \(MVP - VB\)"
>
[quoted text clipped - 63 lines]
> Thanks in Advance,
> Aaron

FIXED IT!   had to remove the "extra room" comment.  very new to VBA,
simple mistake.
Rick Rothstein (MVP - VB) - 18 Jan 2008 21:02 GMT
> > I would love to use this code as well, but i am getting an error. I am
> > using Excel 2004 on Mac OS X Leopard. The error i get is on this
[quoted text clipped - 8 lines]
> FIXED IT!   had to remove the "extra room" comment.  very new to
> VBA, simple mistake.

I've never used the Mac version of Excel so for my own knowledge... are you
saying that VBA in Mac XL2004 doesn't allow for in line comments? I am
surprised by that. Can you use comments (delineated by the apostrophe) by
themselves on their own line?

Rick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.