Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default 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


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the Call Statement caldog Excel Programming 2 January 9th 10 02:59 PM
Variable in call statement donwb Excel Programming 12 April 11th 09 10:18 PM
Call Statement and Return Value [email protected] Excel Programming 3 September 28th 05 08:56 PM
using an if then statement call a caption box to a cell ratt[_2_] Excel Programming 1 June 16th 05 05:30 AM
Can you call a macro as in an IF statement kls[_2_] Excel Programming 2 September 11th 04 10:48 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"