Placement of variables in called sub causes code to fail
On Mar 23, 12:23 pm, Tom Ogilvy
wrote:
the original declaration for exporttofile requires that 3 arguments be passed
to the function and you do not pass any arguments when you call it. This
would be appropriate if the calling procedure needs to pass this information
to the sub or receive this information from the sub or both.
you would then call it like
Sub1() 'in module1
Dim s1 as String, s2 as String, b as Boolean
.....other routines
If bla bla then
Exporttofile s1, s2, b 'in module2
Else
thus if you call it with the required arguments correctly dimensioned, then
it works.
In the second declaration for exporttofile, exporttofile requires no
information and returns no information. All variables are defined and
populated from information/code within the subroutine. Thus when you call it
with no arguments and it requires no arguments, it works.
--
Regards,
Tom Ogilvy
"acampbell" wrote:
Can somebody help me understand why the following code, in sub1 fails
to run but the modifcations to the called sub below that does run? I
was getting "Argument not optional" error.
Alan
Sub1() 'in module1
.....other routines
If bla bla then
Exporttofile 'in module2
Else
.... other routines
Sub Exporttofile (fName As String, Sep As String, SelectionOnly As
Boolean)
code...
Modified Exporttofile:
Sub Exporttofile()
Dim fName As String
Dim Sep As String
Dim SelectionOnly As Boolean- Hide quoted text -
- Show quoted text -
Thank you both for the clarification for properly coding for calling
the second routine.
Alan
|