Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Run this macro whenever the worksheet changes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dancecommander81@hotmail.com - 25 Jan 2006 12:50 GMT
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
Bob Phillips - 25 Jan 2006 13:06 GMT
'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

Signature

HTH

Bob Phillips

(remove nothere from email address if mailing direct)

> Hello,
>
[quoted text clipped - 19 lines]
>     Range("A2").Select
> End Sub
Bob Phillips - 25 Jan 2006 13:19 GMT
Oops that should be

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
   sh.Columns("A:F")..AutoFit
   sh.Range("A2").Select

End Sub

Signature

HTH

Bob Phillips

(remove nothere from email address if mailing direct)

> 'This is workbook event code.
> 'To input this code, right click on the Excel icon on the worksheet
[quoted text clipped - 32 lines]
> >     Range("A2").Select
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.