View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
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.