In Excel VBA, we can use function when we are performing repetitive tasks like data formatting, calculations and so on. With Excel VBA, we can create a function that returns a value when the function is used. This article looks at how to return a value from a function using VBA Excel.
Figure 1: Return value function with VBA
Return a value using exit function or End function
When conducting a function procedure, you need to assign a value to the procedure’s name. After you have assigned the name, you will have the value that was most recently assigned to the procedure returned when an Exit or End function is executed.
Note that with VBA, we can have more than one Exit function statement as well as mix Return and Exit function statement in same procedure.
Instant Connection to an Expert through our Excelchat Service
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.