run Public Sub from Public Function

Pirate

Registered User.
Local time
Tomorrow, 03:18
Joined
Jun 17, 2009
Messages
23
In my macro I am using the Action "Run Code" but my code is a Public Sub, It tells me to call the Sub by using a Function.
MyFuncition is:

Public Function QuantitySub()
CallPulicSub "Quantity()"
End Function
There is no error messages after I have written the code.
When I run the macro I receive the message

Compile Error: Sub or function not defined.

Any clues

Pirate
 
Public Function QuantitySub()
CallPulicSub "Quantity()"
End Function
There is no error messages after I have written the code.
When I run the macro I receive the message

Compile Error: Sub or function not defined.

Any clues

Pirate
Spell PUBLIC correctly, put a space between CALL and "Public Sub", drop the quote marks around the function name.
 
As a FYI- you can use function as if it was a sub without need to call a sub:

Code:
Public Function Foo()

End Function

This will return a variant, but we don't care what it will actually return but at least it can be called and it is more straightforward to do so.

HTH.
 
Thanks
I have tried this

Public Function QuantitySub()
Call Public Sub Quantity()
End Function
and
Public Function QuantitySub()
Call "Public Sub" Quantity()
End Function
and this
Public Function QuantitySub()
Call PublicSub Quantity()
End Function
Still receive error messages can you still see an error.

Steve
 
Erm. No.

Code:
Public Function QuantitySub()
Call Quantity()
End Function

Public Sub Quantity()

End Sub

Also, this is unnecessary since you could just make the Sub a function and forget about it.
 
Thanks
I have tried this

Public Function QuantitySub()
Call Public Sub Quantity()
End Function
and
Public Function QuantitySub()
Call "Public Sub" Quantity()
End Function
and this
Public Function QuantitySub()
Call PublicSub Quantity()
End Function
Still receive error messages can you still see an error.

Steve
have you tried this?
Code:
Call Quantity()
 
Thank you for your help that part works well.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom