ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to ajust columns! (https://www.excelbanter.com/excel-programming/306516-macro-ajust-columns.html)

tratliff[_3_]

Macro to ajust columns!
 
I have a workbook with @50 tabs. Each tab is setup the same. I want t
autofit certain columns (F, H, L, M) on all tabs. There are hidden tab
(G, I, J, K) that I do not want to autofit.

please help!!

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Macro to ajust columns!
 
for each sh in Thisworkbook.Worksheets
sh.Range("F:F,H:H,L:M").EntireColumn.Autofit
Next

--
Regards,
Tom Ogilvy

"tratliff " wrote in message
...
I have a workbook with @50 tabs. Each tab is setup the same. I want to
autofit certain columns (F, H, L, M) on all tabs. There are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from http://www.ExcelForum.com/




djh

Macro to ajust columns!
 
Try this.

Creat a Macro:

Sub AutoFix()
Range("F:F,H:H,L:M").Columns.AutoFit
End Sub

Then for each worksheet:
Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
AutoFit
End Sub

-----Original Message-----
I have a workbook with @50 tabs. Each tab is setup the

same. I want to
autofit certain columns (F, H, L, M) on all tabs. There

are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from http://www.ExcelForum.com/

.


sp00nix[_17_]

Macro to ajust columns!
 
Sub quickFit()
For Each sht In ActiveWorkbook.Worksheets
sht.Columns("F:F").EntireColumn.AutoFit
sht.Columns("H:H").EntireColumn.AutoFit
sht.Columns("L:L").EntireColumn.AutoFit
sht.Columns("M:M").EntireColumn.AutoFit
Next sht
End Sub



try that


---
Message posted from http://www.ExcelForum.com/


Don Guillett[_4_]

Macro to ajust columns!
 
try

Sub autofitcols()
for each ws in worksheets
ws.Range("f1,h1,l1,m1").Columns.AutoFit
next
End Sub

--
Don Guillett
SalesAid Software

"tratliff " wrote in message
...
I have a workbook with @50 tabs. Each tab is setup the same. I want to
autofit certain columns (F, H, L, M) on all tabs. There are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from
http://www.ExcelForum.com/




sp00nix[_16_]

Macro to ajust columns!
 
This way is a little more "politically correct" from a programmer's
perspective. Very easy to update without having to changing too many
lines.


Code:
--------------------

Sub AutoFitCertainColumns()

AutoFitCols = Array( _
"F:F", _
"H:H", _
"L:L", _
"M:M" _
)

For Each sht In ActiveWorkbook.Worksheets
For i = 1 To UBound(AutoFitCols)
sht.Columns(AutoFitCols(i)).EntireColumn.AutoFit
Next i
Next sht
End Sub

--------------------



---
Message posted from http://www.ExcelForum.com/


No Name

Macro to ajust columns!
 
Both Don's and Tom's Marcos are good for a one time
event.

But to Auto Fit columns on the fly, it must be tied to an
event for the worksheet. Using their Macros for a
worksheet event would result in reforming the four columms
on the 50 sheet every time the event occurs.


-----Original Message-----
I have a workbook with @50 tabs. Each tab is setup the

same. I want to
autofit certain columns (F, H, L, M) on all tabs. There

are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from http://www.ExcelForum.com/

.


Tom Ogilvy

Macro to ajust columns!
 
There was no talk by the original poster of having the action performed on
Entry, or on the fly as you state - thus requiring an event. If that were
the case, the one solution offered, using the worksheet event, would need to
be entered in 50 sheets and would autofit all 4 columns on each changed of
selection. If on the fly was the requirement, the the workbook level event
would be appropriate and only one column would possibly be changed based on
the change events target property. I never suggested that my code should be
called from an event.


--
Regards,
Tom Ogilvy


wrote in message
...
Both Don's and Tom's Marcos are good for a one time
event.

But to Auto Fit columns on the fly, it must be tied to an
event for the worksheet. Using their Macros for a
worksheet event would result in reforming the four columms
on the 50 sheet every time the event occurs.


-----Original Message-----
I have a workbook with @50 tabs. Each tab is setup the

same. I want to
autofit certain columns (F, H, L, M) on all tabs. There

are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from http://www.ExcelForum.com/

.




Don Guillett[_4_]

Macro to ajust columns!
 
ditto

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
There was no talk by the original poster of having the action performed on
Entry, or on the fly as you state - thus requiring an event. If that were
the case, the one solution offered, using the worksheet event, would need

to
be entered in 50 sheets and would autofit all 4 columns on each changed of
selection. If on the fly was the requirement, the the workbook level

event
would be appropriate and only one column would possibly be changed based

on
the change events target property. I never suggested that my code should

be
called from an event.


--
Regards,
Tom Ogilvy


wrote in message
...
Both Don's and Tom's Marcos are good for a one time
event.

But to Auto Fit columns on the fly, it must be tied to an
event for the worksheet. Using their Macros for a
worksheet event would result in reforming the four columms
on the 50 sheet every time the event occurs.


-----Original Message-----
I have a workbook with @50 tabs. Each tab is setup the

same. I want to
autofit certain columns (F, H, L, M) on all tabs. There

are hidden tabs
(G, I, J, K) that I do not want to autofit.

please help!!!


---
Message posted from
http://www.ExcelForum.com/

.







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

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