How to Use the CALL Function in Excel
Welcome to the detailed guide on how to use the CALL function in Microsoft Excel and Google Sheets. The CALL function in these spreadsheet programs allows you to invoke a macro function either by its name or by a reference.
Using CALL Function in Excel and Google Sheets
The syntax for the CALL function is as follows:
=CALL(function_name, argument1, argument2, ...)
Where:
- function_name: The name of the macro function you wish to invoke.
- argument1, argument2, …: The parameters that will be passed to the function.
Examples of Using the CALL Function:
Here are a few examples to demonstrate the functionality of the CALL function.
Example 1 – Simple Addition Function:
Imagine a macro function called AddNumbers
that accepts two arguments and returns their sum. It is defined as follows:
Function AddNumbers(num1, num2) AddNumbers = num1 + num2 End Function
To invoke this function using the CALL function in Excel or Google Sheets, you would use the formula:
=CALL("AddNumbers", 5, 10)
This will yield the result 15
by adding 5 and 10 together.
Example 2 – Dynamic Function Call:
Assume you have a list of function names in cells A1:A3 (e.g., AddNumbers, SubtractNumbers, MultiplyNumbers) and you want to dynamically call one of these functions based on the value in cell B1. You could use the following formula:
A | B | C |
---|---|---|
AddNumbers | 5 | =CALL(B1, 10, 15) |
In this scenario, if cell B1 contains AddNumbers
, the formula will invoke the AddNumbers
function with arguments 10 and 15, producing the resultant output.
These examples illustrate how the CALL function can be utilized to dynamically invoke macro functions in Excel and Google Sheets.
More information: https://support.microsoft.com/en-us/office/call-function-32d58445-e646-4ffd-8d5e-b45077a5e995