Calling Macro

  • Thread starter Thread starter fi.or.jp.de
  • Start date Start date
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.
 
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.
 
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
 
Back
Top