ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofit (https://www.excelbanter.com/excel-programming/376529-autofit.html)

Jentan

Autofit
 
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.


Gary Keramidas

Autofit
 
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

--


Gary


"Jentan" wrote in message
oups.com...
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.





All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com