Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Paul987
 
Posts: n/a
Default Starting/Stopping Worksheet Event Code


I have some code courtesy of a contributor here, that I need to start or
stop on command. My problem is that when I open the sheet, the code
kicks an error because some other macros havn't finished running yet.
Is there a way I can assign a button that would start/stop this event
code? TIA

Here is the code:


Private Sub Worksheet_Calculate()
Const WS_RANGE As String = "A1:H10"
Static oldvalue

If Me.Range(WS_RANGE) < oldvalue Then
If Me.Range(WS_RANGE).Value <= 1 Then
MsgBox "Alert"
End If
End If
oldvalue = Me.Range(WS_RANGE).Value
End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
Paul987
------------------------------------------------------------------------
Paul987's Profile: http://www.excelforum.com/member.php...o&userid=24850
View this thread: http://www.excelforum.com/showthread...hreadid=524423

  #2   Report Post  
Posted to microsoft.public.excel.misc
flummi
 
Posts: n/a
Default Starting/Stopping Worksheet Event Code

make sure the control toolbox is available (view--toolbars--control
toolbox
click the green triangle
click the command button icon
draw a command button
right click it and select "view code"
put your code between Private Sub CommandButton1() and End Sub
delete the code from the worksheet event
click the green triangle

If you now click the command button it will run the code.

Hope this was what you requested.

Hans

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
Event macro that targets specific worksheet retseort Excel Discussion (Misc queries) 3 February 20th 06 02:47 PM
VBA code to Add data to exsiting worksheet jonesaa05 Excel Discussion (Misc queries) 7 October 14th 05 01:20 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"