logo
Microsoft Excel - Interview Questions and Answers
What is the difference between a function and a subroutine in VBA?

Functions

Subroutines 

A function is responsible for returning the value of the task it is performing.

Meanwhile, subroutines don’t return the value of the task it is performing.

They are called by a variable.

They can be recalled from anywhere in the program, in multiple types.

Functions are used as it is in spreadsheets as formulas.

Subroutines are not used directly in spreadsheets as formulas.

Functions are used to carry out repetitive tasks, and it, in turn, returns a value.

Users are required to insert a value in the desired cell before fetching the result of the subroutine.