Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Hide columns | Excel Discussion (Misc queries) | |||
going 3 columns over in a macro | New Users to Excel | |||
Macro lookup columns | Excel Discussion (Misc queries) | |||
insert columns macro is putting 2 columns instead of 1 | Excel Worksheet Functions | |||
macro to unmerge columns | Excel Discussion (Misc queries) |