Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling code using a button?

Does anyone know how to stop all the code working in a workbook b
clickin an added button and then allowing the code to be active agai
on the next click of that button?

Thanks!

Simo

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling code using a button?

That is not too hard....

Public StartStopCode As Boolean

Private Sub Button_Click()

If StartStopCode = True Then
StartStopCode = False
Else: StartStopCode = True
End If

End Sub

Private Sub MyCode()
If StartStopCode = False Then

' Your code here

End If
End Su

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling code using a button?

Thanks Berend, but im fairly new to this and the first part of the cod
looks like a loop startstopcode=True Then startstopcode=False, als
where do i put this?...in the Thisworkbook code?

Hope you can advise.

Simo

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Disabling code using a button?

One way is to add a macro to the button that will put "No"
in cell A1 for example

Sub test()
With Sheets("Sheet1").Range("A1")
If .Value = "No" Then
.Value = "Yes"
Else
.Value = "No"
End If
End With
End Sub

And in all your other macro's add this line at the top
If Sheets("Sheet1").Range("A1").Value = "No" Then Exit Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Simon Lloyd " wrote in message ...
Does anyone know how to stop all the code working in a workbook by
clickin an added button and then allowing the code to be active again
on the next click of that button?

Thanks!

Simon


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling code using a button?

Ron Can that .Value=0 be in any cell i choose, need the code to b
disabled because i have a lot of worksheet selection_change code s
when on the spread sheet you try to drag and select rows and or column
the events try to take place and crash the program thats why i need t
add a button to the menubar that turns of this code until presse
again!

Simo

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling code using a button?

Just put the whole code in the code of the worksheet the button (and th
data) is on. It should work then

--
Message posted from http://www.ExcelForum.com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Disabling code using a button?

Ron Can that .Value=0 be in any cell i choose
yes you can choose the cell

You can disable events like this also
Application.EnableEvents = False




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Simon Lloyd " wrote in message ...
Ron Can that .Value=0 be in any cell i choose, need the code to be
disabled because i have a lot of worksheet selection_change code so
when on the spread sheet you try to drag and select rows and or columns
the events try to take place and crash the program thats why i need to
add a button to the menubar that turns of this code until pressed
again!

Simon


---
Message posted from http://www.ExcelForum.com/



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
Disabling Excel X Application Button Nigel[_8_] Excel Programming 18 April 18th 04 07:13 AM
disabling a command button Paul James[_3_] Excel Programming 16 February 18th 04 07:10 AM
VB code for disabling DJ Excel Programming 2 November 10th 03 09:01 AM
disabling cells based on cmd button Consuelo Excel Programming 1 September 20th 03 09:44 AM
Disabling font color button Michael Singmin Excel Programming 1 September 16th 03 10:32 PM


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