Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Run-once macro

Hi All...........
Is there a way to have a SelectionChange macro set up so it will run the
first time it's called upon, and as a last item, disable itself to never run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Run-once macro

You could have the macro, as the first step, check what ever unique
condition it imposes and if it appears it has run, then exit.

It will still run, but will exit without doing anything.

--
Tom Ogilvy


"CLR" wrote:

Hi All...........
Is there a way to have a SelectionChange macro set up so it will run the
first time it's called upon, and as a last item, disable itself to never run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Run-once macro

There are probably a number of ways, but I would get it to create a Name
(hidden) with a particular reference when it runs. Then, at the start of the
SelectionChange event you could look at the name to see the value and run it
or not based on that.

Jeff

"CLR" wrote in message
...
Hi All...........
Is there a way to have a SelectionChange macro set up so it will run the
first time it's called upon, and as a last item, disable itself to never
run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run-once macro

Chuck,

Try something like


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
www.cpearson.com




"CLR" wrote in message
...
Hi All...........
Is there a way to have a SelectionChange macro set up so it
will run the
first time it's called upon, and as a last item, disable itself
to never run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3



  #5   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Run-once macro

Cool........that should work for my immediate requirement.........

Thanks, Tom

Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote:

You could have the macro, as the first step, check what ever unique
condition it imposes and if it appears it has run, then exit.

It will still run, but will exit without doing anything.

--
Tom Ogilvy


"CLR" wrote:

Hi All...........
Is there a way to have a SelectionChange macro set up so it will run the
first time it's called upon, and as a last item, disable itself to never run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3



  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Run-once macro

Ah-ha..........increased security......

Thanks, Jeff

Vaya con Dios,
Chuck, CABGx3



"Jeff Standen" wrote:

There are probably a number of ways, but I would get it to create a Name
(hidden) with a particular reference when it runs. Then, at the start of the
SelectionChange event you could look at the name to see the value and run it
or not based on that.

Jeff

"CLR" wrote in message
...
Hi All...........
Is there a way to have a SelectionChange macro set up so it will run the
first time it's called upon, and as a last item, disable itself to never
run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3




  #7   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Run-once macro

Hey now....THAT is some cool.........Thanks Chip.

Vaya con Dios,
Chuck, CABGx3



"Chip Pearson" wrote:

Chuck,

Try something like


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
www.cpearson.com




"CLR" wrote in message
...
Hi All...........
Is there a way to have a SelectionChange macro set up so it
will run the
first time it's called upon, and as a last item, disable itself
to never run
again unless "reset"?

TIA
Vaya con Dios,
Chuck, CABGx3




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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 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 01:44 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"