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

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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





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
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 01:11 PM.

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

About Us

"It's about Microsoft Excel"