![]() |
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 |
All times are GMT +1. The time now is 02:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com