Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Run Auto Macro only once

I need to run an Auto Macro only the first time a file is opened. On
subsequesnt opening of the file, no action should occur. Any help is
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Run Auto Macro only once

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Res As Variant
On Error Resume Next
Res = ThisWorkbook.Names("RunOnce").Value
If IsEmpty(Res) Then
MsgBox "Run Once Code"
End If
ThisWorkbook.Names.Add "RunOnce", "TRUE"


End Sub


You can reset it by deleting the name "RunOnce"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC



--
Don Guillett
SalesAid Software

"Jim D" wrote in message
...
I need to run an Auto Macro only the first time a file is opened. On
subsequesnt opening of the file, no action should occur. Any help is
appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,345
Default Run Auto Macro only once

Have the Macro look for some value in a cell, (which may be a hidden cell if
you wish), and quit if it finds it. Later in the Macro have the Macro place
the value that it will look for the next time that it runs. The Macro will
therfore only run the first time or if you delete the value in the cell.


--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"Jim D" wrote in message
...
I need to run an Auto Macro only the first time a file is opened. On
subsequesnt opening of the file, no action should occur. Any help is
appreciated.



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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro Auto Run(2) Gary Excel Worksheet Functions 4 May 18th 06 09:07 AM
Macro - Auto Run Gary Excel Worksheet Functions 1 May 12th 06 08:29 PM
macro for auto sum ahemani New Users to Excel 2 July 29th 05 12:53 AM
Auto Run a Macro Pam Coleman Excel Discussion (Misc queries) 2 May 3rd 05 02:58 PM


All times are GMT +1. The time now is 08:31 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"