Runtime error '3' : Exit without Gosub

  • Hi all,


    I am trying to use functions in VBA.


    I have a simple fundtion which does some operations. At the end of function, I want the code to resume from the next line of the code where I called this function from. I am getting the error message:
    " Runtime error '3'
    Exit without GoSub"


    Can anyone help me?
    The following is the code:


    I am new to using functions. So, pardon me if i am not using the correct syntax. Please enlighten me.


    Thanks


    Cheers
    Yogesh

  • Re: Runtime error '3' : Exit without Gosub


    Take out the 'Return' - the code will implicitly return to the calling procedure.


    Also, please have another read of the rules you agreed to when you joined the forum (http://www.ozgrid.com/forum/announcement.php?f=8) - code must be bracketed with Code tags, not than Quote tags.


    Please edit you post and replace [noparse]

    Quote

    [/noparse] with [noparse]

    Code
    [/noparse][/b] and [noparse][/quote][/noparse] with [b][noparse]

    [/noparse][/b].

  • Re: Runtime error '3' : Exit without Gosub


    Thanks for the reply.


    But when i remove the code, i get the error message:
    "Runtime error '13' - Type mismatch"


    and sorry about the tags i used. Will be more careful next time.


    Thanks


    Cheers:
    Yogesh

  • Re: Runtime error '3' : Exit without Gosub


    Post your code -

    Code
    Calc(Void)

    means nothing in VBA - I don't know if you're just using that as a sample or not so need the code to be absolutely sure what you're doing/trying to do.


    Also, while it's appreciated you'll be more careful in future - please edit your first post in this thread to comply with the rules...

  • Re: Runtime error '3' : Exit without Gosub


  • Re: Runtime error '3' : Exit without Gosub


    I use Calc(void) because i am not passing any arguments to the function. The function is just a block of code which performs some basic operations in excel like copying and pasting and stuff. I am using this function because i want the same operations to be performed at various cell ranges in same sheet.


    I am not sure how to go about calling a function without passing any arguements. Thats why i used void.


    Hope you understand.


    Thanks


    Cheers
    Yogesh

  • Re: Runtime error '3' : Exit without Gosub


    There's no such type as VOID in VBA - call the function without parameters as in Truntens reply if the variable j is scoped to the module or is Public


    More properly, it should be written as:


  • Re: Runtime error '3' : Exit without Gosub


    Oh thanks a lot. I understood where i was going wrong.


    I was using ' Calc() ' to call the function. Its simply ' Calc ' to call the function. I did not know this.


    Now, its working all right.


    Cheers
    Yogesh

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!