View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default Excel column autofit

As long as things work, that's fine...I won't tell anyone ;-)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"J. M. De Moor" wrote in message
...
Hey Nick

Thanks for your post.


Sub Test()
Columns("C:C").WrapText = True
Columns("A:Q").AutoFit
End Sub


Unfortunately this doesn't work because the text wraps on word break,
where I would like to have it wrap only on the line feed. Also I can't
predict which column will have the line feeds. (The output is from an ad
hoc query in SQL Server.) If you are curious, the way I ended up working
around it is to make the default column width on the template wider than I
expect a single line (to the line feed) to be. Then the Autofit trims it
nicely.

Not elegant, but it is working...

Joe