Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
djh djh is offline
external usenet poster
 
Posts: 8
Default 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/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default 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/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #7   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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/

.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/

.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Hide columns whatzzup Excel Discussion (Misc queries) 3 October 23rd 09 01:39 PM
going 3 columns over in a macro ben New Users to Excel 5 September 15th 08 06:55 PM
Macro lookup columns Martincito23 Excel Discussion (Misc queries) 2 January 26th 07 05:42 PM
insert columns macro is putting 2 columns instead of 1 AGH Excel Worksheet Functions 2 February 27th 06 02:36 PM
macro to unmerge columns HankY Excel Discussion (Misc queries) 2 December 8th 05 06:04 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"