PC Review


Reply
Thread Tools Rate Thread

Calling Macro

 
 
fi.or.jp.de
Guest
Posts: n/a
 
      15th May 2010
Hi All,

I have macro like this

sub unique()

''''''''
''''''''
Counter_item = 0
For Each Item In nodups
counter_item = counter_item + 1
bic_var = Item
Call Ps_Match
Next Item

end sub

I have another macro

Sub Ps_Match()
'''''
'''''
If counter_item <= 1 Then
call another_macro()
end if
end sub

In the first macro i am declaring counter_item equals to 1.

In my second macro i need to call that number.


 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      15th May 2010
At the to of the module put:

Public Counter_Item As Long

It has to be outside the macro and then either macro can use and set the
value of it.

"fi.or.jp.de" <(E-Mail Removed)> wrote in message
news:838dedc3-43b9-455b-acbd-(E-Mail Removed)...
> Hi All,
>
> I have macro like this
>
> sub unique()
>
> ''''''''
> ''''''''
> Counter_item = 0
> For Each Item In nodups
> counter_item = counter_item + 1
> bic_var = Item
> Call Ps_Match
> Next Item
>
> end sub
>
> I have another macro
>
> Sub Ps_Match()
> '''''
> '''''
> If counter_item <= 1 Then
> call another_macro()
> end if
> end sub
>
> In the first macro i am declaring counter_item equals to 1.
>
> In my second macro i need to call that number.
>
>



 
Reply With Quote
 
Rik_UK
Guest
Posts: n/a
 
      15th May 2010
Hi

Global variables work, but it is also good practice to pass variables beween
proceedures.

sub unique()
Dim counter_item as integer 'declare variable
''''''''
''''''''
counter_item = 0
For Each Item In nodups
counter_item = counter_item + 1
bic_var = Item
Call Ps_Match (counter_item) 'pass integer data to called process
Next Item

end sub

I have another macro

Sub Ps_Match(cntr_item as integer) 'added variable declaration here
'''''
'''''
If cntr_item <= 1 Then
call another_macro()
end if
end sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a public Macro from a Private Macro =?Utf-8?B?dGhld2l6eg==?= Microsoft Excel Programming 6 2nd Nov 2007 10:23 PM
Calling a Sub from a Macro =?Utf-8?B?S2VubnkgQS4=?= Microsoft Access Macros 2 23rd May 2007 08:46 PM
Calling XLA Macro from DLL. =?Utf-8?B?VCBH?= Microsoft Excel Programming 3 21st Nov 2006 07:37 AM
macro calling another macro + variables =?Utf-8?B?eW8=?= Microsoft Excel Misc 2 5th Apr 2006 04:36 PM
how to disable a macro by calling it from another macro paritoshmehta Microsoft Excel Programming 5 6th May 2004 07:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 PM.