#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default turn off subroutines

I have some private subroutines that I would like to turn off so the
worksheet can be edited manually if incorrect data has been typed in during a
race. Is it possible to turn off some subroutines and leave others working.
The only subroutine I would need to temporarily disable is a private sub
worksheet_change subroutine.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 703
Default turn off subroutines

Hi

Use an unused cell far away from your used range, in this example AA1
as control cell. If you want to turn off the event macro, enter
TurnOff in the cell, and do your changes as needed, then remove the
word to turn it on again.

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("AA1") = "TurnOff" Then Exit Sub
' Here goes your original code

End Sub

Hopes this helps.
....
Per

On 27 Jul., 11:46, NDBC wrote:
I have some private subroutines that I would like to turn off so the
worksheet can be edited manually if incorrect data has been typed in during a
race. Is it possible to turn off some subroutines and leave others working.
The only subroutine I would need to temporarily disable is a private sub
worksheet_change subroutine.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default turn off subroutines

I can make that work thanks, but it gave me another idea. The only time i
need the Private Sub Worksheet_Change(ByVal Target As Range) to work is when
one of my main subs in the public module is going and a form is operating
(the main sub loads and shows the form). Can I put something in these subs
that disables the worksheet_change sub when the form is shut down.

Thanks


"Per Jessen" wrote:

Hi

Use an unused cell far away from your used range, in this example AA1
as control cell. If you want to turn off the event macro, enter
TurnOff in the cell, and do your changes as needed, then remove the
word to turn it on again.

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("AA1") = "TurnOff" Then Exit Sub
' Here goes your original code

End Sub

Hopes this helps.
....
Per

On 27 Jul., 11:46, NDBC wrote:
I have some private subroutines that I would like to turn off so the
worksheet can be edited manually if incorrect data has been typed in during a
race. Is it possible to turn off some subroutines and leave others working.
The only subroutine I would need to temporarily disable is a private sub
worksheet_change subroutine.

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default turn off subroutines

A couple of ways to do that:

declare a public boolean 'flag' and set it to TRUE inside of your form's
code (the Initialize event would be a good place to do that) and just before
you UNLOAD it, set it back to FALSE. Test the status of that flag at the
start of subs you don't want to run when the form is loaded and if it is
TRUE, then just exit the sub, or

Use a routine to test if the form is loaded and call that routine at the
start of the subs you don't want to run and if the form is loaded, again,
just exit the sub. Do a web search for "test if excel form is loaded" and
you'll find several code samples for such a function. Will actually need to
UNLOAD the form for them to work, not just .Hide it.

"NDBC" wrote:

I can make that work thanks, but it gave me another idea. The only time i
need the Private Sub Worksheet_Change(ByVal Target As Range) to work is when
one of my main subs in the public module is going and a form is operating
(the main sub loads and shows the form). Can I put something in these subs
that disables the worksheet_change sub when the form is shut down.

Thanks


"Per Jessen" wrote:

Hi

Use an unused cell far away from your used range, in this example AA1
as control cell. If you want to turn off the event macro, enter
TurnOff in the cell, and do your changes as needed, then remove the
word to turn it on again.

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("AA1") = "TurnOff" Then Exit Sub
' Here goes your original code

End Sub

Hopes this helps.
....
Per

On 27 Jul., 11:46, NDBC wrote:
I have some private subroutines that I would like to turn off so the
worksheet can be edited manually if incorrect data has been typed in during a
race. Is it possible to turn off some subroutines and leave others working.
The only subroutine I would need to temporarily disable is a private sub
worksheet_change subroutine.

Thanks



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
VBA - passing Variables to subroutines Madduck Excel Discussion (Misc queries) 12 September 19th 08 03:20 AM
Turn Off New UI Need_More_Screen New Users to Excel 2 June 24th 06 07:20 PM
WHY DOES 1E4 TURN INTO 1.00 E + 04? THANKS Lisa B. Excel Discussion (Misc queries) 1 July 2nd 05 12:48 AM
How do i turn it off ceemo Excel Discussion (Misc queries) 2 May 25th 05 12:25 PM
how do i turn off the gridlines Ian40Ian Excel Discussion (Misc queries) 1 March 26th 05 04:54 PM


All times are GMT +1. The time now is 06:57 AM.

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"