close

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 = quot;A1:H10quot;
Static oldvalue

If Me.Range(WS_RANGE) lt;gt; oldvalue Then
If Me.Range(WS_RANGE).Value lt;= 1 Then
MsgBox quot;Alertquot;
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: www.excelforum.com/member.php...oamp;userid=24850
View this thread: www.excelforum.com/showthread...hreadid=524423make sure the control toolbox is available (view--gt;toolbars--gt;control
toolbox
click the green triangle
click the command button icon
draw a command button
right click it and select quot;view codequot;
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

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()