HEELPBOOK - How to Autofit Column Widths (VBA) ####################### Somebody could ask for VBA code that will automatically adjust column widths to fit the cell contents. It's actually very simple and all you need is one function call. You simply need to call the AutoFit method. Sub AutoFitAllColumns() ActiveSheet.UsedRange.Columns.AutoFit End Sub If you wanted to autofit the row heights, you'll need something like this: Sub AutoFitAllRows() ActiveSheet.UsedRange.Rows.AutoFit End Sub Just note that for autofit of rows to work, you'll need to have the "Wrap Text" setting turned on. To do that, you need to select the range you want to autofit and from the main menu, go to Format->Cells. Then in the Alignment tab, tick the checkbox for "Wrap Text". ############ ARTICLE INFO ############# Article Month: October Article Date: 26/10/2012 Permalink: http://heelpbook.altervista.org/2012/how-to-autofit-column-widths-vba/ Source: http://www.vadriano.com/excel-vb/2007/04/06/how-to-autofit-column-widths-with-vba/ Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook Follow us on Delicious: http://delicious.com/heelpbook Linkedin: http://it.linkedin.com/pub/stefano-maggi/27/73a/b20 Google+ : https://plus.google.com/116990277568167008289/posts