Inactivating a Sub Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I am using another Sub Function, I wants to inactivate another Sub
function.
Please suggest how can we do it?
 
You can use a boolean

Ad the top of your module add
Public stoprun As Boolean

In the sub you can set it to True and in the other one use this (first line)

If stoprun = True Then Exit Sub
 
I assume you want to run a macro from another macro


Application.Run "Book1!Macro1"
example:
Sub Macro4()
'
' Macro4 Macro
'
Range("G18").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-15]C:R[-1]C)"
Range("G19").Select

Application.Run "Book1!Macro1"

End Sub
 
Dear Mr.Ron de Bruin,
Thanks for your Immediate reply.
Let me explain for which reason I asked this question to you.
Actually, I am creatng an Excel Program with VBA in which I had 20 cells as
Data Input to the users. It will be blanked cells. Hence user will fill the
cells for results.
So the user should not avoid each cell as those cells are imperitus for
result.
Hence I wrote the program (in Sub Function) for the above protocal.
Now the problem is created for me. Actually I am having another command
button which will clear all the contents in the cells once if the program
shows the results. So by this time, I should use the suggestions given by
you. I feel better if you can advise in a brief manner further for this one.
Please do not mistake me.
Thankyou,
Regards,
Premanand.S
 
No Mr.Dave,
I wish to"not to run" a Sub function /Inactivate a Sub Function when I will
use another Function/Command Button.
I explained the program in detail in my previous thread.
Please Suggest me futher.
Regards,
Premanand Sethuraman.
 
If you have a change event to fire when the cells are edited, then you can
suppress this with EnableEvents:

Private Sub CommandButton1_Click()
On Error goto ErrHandler
Application.EnableEvents = False
Range("A1:M20").ClearContents
ErrHandler:
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top