ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inactivating a Sub Function (https://www.excelbanter.com/excel-programming/360779-inactivating-sub-function.html)

Premanand

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

Ron de Bruin

Inactivating a Sub Function
 
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


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


"Premanand" wrote in message ...
When I am using another Sub Function, I wants to inactivate another Sub
function.
Please suggest how can we do it?




davesexcel[_109_]

Inactivating a Sub Function
 

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


--
davesexcel


------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=539633


Premanand

Inactivating a Sub Function
 
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

"Ron de Bruin" wrote:

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


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


"Premanand" wrote in message ...
When I am using another Sub Function, I wants to inactivate another Sub
function.
Please suggest how can we do it?





Premanand

Inactivating a Sub Function
 
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.

"davesexcel" wrote:


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


--
davesexcel


------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=539633



Tom Ogilvy

Inactivating a Sub Function
 
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

--
Regards,
Tom Ogilvy


"Premanand" wrote:

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

"Ron de Bruin" wrote:

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


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


"Premanand" wrote in message ...
When I am using another Sub Function, I wants to inactivate another Sub
function.
Please suggest how can we do it?






All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com