Autofit

J

Jentan

Hi,

I have this aotufit command but it doesn't really work.

Sub col()

On Error Resume Next
'For Each ws In Workbooks("bbl.xls").Sheets


For Each Sh In Workbooks("bbl.xls")
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Columns.AutoFit
'ActiveSheet.ActivateNext

Next

End Sub


I am trying to make an automatic "autofit" to each of the tabs in a
workbook irregardless of the tab name and number of column in each of
the tab.

Can I have a command that can work? Thank you.
 
G

Gary Keramidas

this worked for me

Sub col()
Dim sh As Worksheet
On Error Resume Next
For Each sh In ThisWorkbook.Sheets
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Columns.AutoFit
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top