Call Statement
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 |
Call Statement
sub docall() xxxxxxxx ssss call repeat ssssss ssss call repeat end sub -- Don Guillett Microsoft MVP Excel SalesAid Software "caldog" wrote in message ... 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 |
Call Statement
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 |
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 . |
Call Statement
I always assumed that the "call" statement was used for setting a macro to a
button/checkbox...etc Private Sub CommandButton1_Click() Call #Name End Sub "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 |
All times are GMT +1. The time now is 09:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com