#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default macro run


How is it possible to start a macro immidiately after the Excel file is
opened?


Name the macro Auto_Open or use the Workbook_Open event procedure in the
ThisWorkbook code module. The difference between these methods is that
Auto_Open will not run if the workbook is opened via VBA code, while
Workbook_Open will run regardless of how the workbook is opened (assuming
EnableEvents is True).

My other question is: how is it possible to run a macro when I step into a
specified cell?

Use SelectionChange event. In the code module of the worksheet containing
the cell, use code like the following. This will run the 'your code here'
code if the user selects cell A10.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then
Exit Sub
End If
On Error GoTo ErrH:
If Target.Address = "$A$10" Then
Application.EnableEvents = False
'''''''''''''''''''''''
' your code here
'''''''''''''''''''''''
End If
ErrH:
Application.EnableEvents = True
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"tomi12619" <tomi12619@laptop wrote in message
...
Hi

How is it possible to start a macro immidiately after the Excel file is
opened?
My other question is: how is it possible to run a macro when I step into a
specified cell?

Thank you in advance.
Thomas

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
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:07 PM.

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

About Us

"It's about Microsoft Excel"