make range available to another macro

S

Steve

I have a procedure which sets a range to a variable:
Set copyrng = Range(HotStringStart, HotStringEnd)

The procedure then calls a separate macro, but the macro doesn't
recognize the range.

The range is available to the procedure it resides in but not to the
called macro. I am using the Public statement at the beginning of the
procedure

How can I allow copyrng to be used in the called macro. I am trying to
copy each cell in copyrng and write it to a text file.

Thanks...
 
P

paul.robinson

Hi
Put the public declaration at the top of the code module

Public copyrng as Range

sub macro1()
'''
end sub

sub macro2()
'''end sub

etc

if both subs are in the same code module you can use Dim rather than
public too, but it still goes at the top of the module outside the
procedures.

regards
Paul
 

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