![]() |
workbook macro help
Hello there, I would like some help with a macro that I need to run in
a workbook. this is the macro. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Columns("A:Z").EntireColumn.AutoFit End Sub what or how do I get it to work for every worksheet in the workbook, I currently place the macro in each worksheet which is very time consuming. Is there a way to place the macro in the workbook so all worksheets have the autofit macro? and can I single out a worksheet so as not to have the macro. regards Ditchy |
Ditchy,
Probably better to use the Change event than the Select event, as the latter shouldn't need a resize. This code goes in tghe ThisWorkbook code module Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) sh.Columns("A:Z").EntireColumn.AutoFit End Sub -- HTH RP (remove nothere from the email address if mailing direct) "ditchy" wrote in message ups.com... Hello there, I would like some help with a macro that I need to run in a workbook. this is the macro. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Columns("A:Z").EntireColumn.AutoFit End Sub what or how do I get it to work for every worksheet in the workbook, I currently place the macro in each worksheet which is very time consuming. Is there a way to place the macro in the workbook so all worksheets have the autofit macro? and can I single out a worksheet so as not to have the macro. regards Ditchy |
thank you Bob and KL for your help, it has solved my problem. Much
appreciated Ditchy |
All times are GMT +1. The time now is 01:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com