What is an Argument in Excel?
An argument in Excel is a value or a cell reference that is passed to a function, formula, or macro. Arguments pass the information to a function, formula, or macro. Arguments are typically used to calculate a value or to perform some action.
Argument of Functions
To see the arguments of a function, type the function name following an equal sign (=). Then enter an opening parenthesis “(“. At this point, the argument of that particular function will be visible.
You can enter arguments in a number of ways, but the most common is to enter them in a cell. For example, the following formula uses the SUM function, which takes one or more arguments:
In this example, the range A1:A5 is the first and only argument inside the SUM function. The function will then add up all of the values in that range and return the result.
You can also enter arguments directly into a function. For example, the following formula also uses the SUM function, but this time the arguments are being entered directly into the function:
In this example, the numbers 1 through 5 are the arguments being passed to the SUM function. The function will then add up all of those numbers and return the result.
Argument of Macros
An argument in Excel VBA is a value or a reference to a value that is passed to a procedure. For example, when you call a procedure with the following syntax:
MyProcedure arg1, arg2, arg3
arg1, arg2, and arg3 are the arguments that are passed to the procedure MyProcedure. Procedures can have up to 60 arguments.
Arguments can be values (such as numbers, strings, or objects) or references to values (such as ranges or worksheets).
When you pass a value as an argument, the procedure makes a copy of the value and uses that copy as the argument.
When you pass a reference as an argument, the procedure uses the value that the reference points to.
You can use optional arguments in procedures. Optional arguments are arguments that don’t have to be passed to a procedure. They are assigned a default value if they are not passed. For example, the following procedure has two optional arguments. The first argument has a default value of 1, and the second argument has a default value of “Hello”:
MyProcedure(Optional arg1 As Integer = 1, Optional arg2 As String = "Hello")
I tried to give you a detailed idea regarding the arguments in Excel. I hope, you will find this article useful. If you have any queries regarding arguments in Excel, feel free to share them with us. Thanks!