Calling Macro

F

fi.or.jp.de

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.
 
J

JLGWhiz

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.
 
R

Rik_UK

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top