Call Statement
I always figured that "Call" was best used in a button.
Private Sub CommandButton1_Click()
Call set_app
End Sub
this way you can code and click a button for the macro to be active...
"Gord Dibben" wrote:
Small example with the two Subs in a module to set application properties
when running macros.
Sub set_app()
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.DisplayAlerts = False
End With
End Sub
Sub reset_app()
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
You don't really need the Call statement to add those to your macros.
Sub do_stuff()
set_app
your code to do stuff
reset_app
End Sub
If you wanted to post an example of what 10 lines you duplicate in 5
different routines perhaps you could get more specifics.
Gord Dibben MS Excel MVP
On Sat, 9 Jan 2010 12:44:01 -0800, caldog
wrote:
I know that there is something that is call a 'call statement', but I do not
know how its work. In my code I duplicate about 10 lines in five different
sections of code. What I was wanting to do, was locate the code that I use
quite a bit in one section and then just ask for when I need it.
Thanks
.
|