![]() |
Run this macro whenever the worksheet changes
Hello,
I have the following macro which I wish to run everytime the contents of any cell is changed in the worksheet. Could someone please advise? Many thanks, Richard Thorneycroft Sub AutofitSelection() ' ' AutofitSelection Macro ' Macro recorded 25/01/2006 by RT ' ' Columns("A:F").Select Range("F1").Activate Selection.Columns.AutoFit Range("A2").Select End Sub |
Run this macro whenever the worksheet changes
'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code Private Sub Workbook_SheetActivate(ByVal Sh As Object) Columns("A:F").Select Range("F1").Activate Selection.Columns.AutoFit Range("A2").Select End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) wrote in message oups.com... Hello, I have the following macro which I wish to run everytime the contents of any cell is changed in the worksheet. Could someone please advise? Many thanks, Richard Thorneycroft Sub AutofitSelection() ' ' AutofitSelection Macro ' Macro recorded 25/01/2006 by RT ' ' Columns("A:F").Select Range("F1").Activate Selection.Columns.AutoFit Range("A2").Select End Sub |
Run this macro whenever the worksheet changes
Oops that should be
Private Sub Workbook_SheetActivate(ByVal Sh As Object) sh.Columns("A:F")..AutoFit sh.Range("A2").Select End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Bob Phillips" wrote in message ... 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code Private Sub Workbook_SheetActivate(ByVal Sh As Object) Columns("A:F").Select Range("F1").Activate Selection.Columns.AutoFit Range("A2").Select End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) wrote in message oups.com... Hello, I have the following macro which I wish to run everytime the contents of any cell is changed in the worksheet. Could someone please advise? Many thanks, Richard Thorneycroft Sub AutofitSelection() ' ' AutofitSelection Macro ' Macro recorded 25/01/2006 by RT ' ' Columns("A:F").Select Range("F1").Activate Selection.Columns.AutoFit Range("A2").Select End Sub |
All times are GMT +1. The time now is 09:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com