• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Speed of Sub vs. Function when not returning a value?

BizJack

New Member
Hi,
I know that we rather use a Sub than a Function when we do not return a value from a procedure.
However, here is a case whereby all the code (even when not returning a value) has been written with Functions instead of Subs.
Before changing everything (quite a task), I wonder:
In terms of execution speed for large procedures (not returning a value) which are repeated often, is a Sub faster than a Function, or slower, or the same?
Has anyone tested it or any clue about that?
In advance, thank you! :)
Best regards,
Jack
 
Jack

I doubt there is any difference in the speed of a Sub or Function.
Both are simply VBA and will run at the same speed when doing the same work
Functions return values and Subroutines don't, although they can be written to write data back to Excel.

Most Sub's slow down when passing data through the Excel/VBA interface, although this is minimised when passing data through as array, rather than cell by cell

Can you be more specific about what you are doing and why you want to transfer it from a Function to a Subroutine ?

http://www.excelfunctions.net/VBA-Functions-And-Subroutines.html
 
Thanks Hui.
I don't need to transfer from Functions to Subroutines. But since the Functions are not returning values and that Subs are meant for that, I was just wondering if a speed gain could be possible.
All the best!
Jacques
 
Back
Top