Lesson#10 Functions in VBA Flashcards
What are the 3 types of functions you can use in VBA?
VBA Built-in, Excel Worksheet and User-Defined.
How do you use a VBA built-in function?
By calling it.
What types of arguments can you use when working with VBA built-in functions?
Named and Unnamed.
How do you separate an argument’s name from it’s value when working with named arguments? (VBA Built-in)
:=
What statement do you use to call a worksheet function?
Application.WorksheetFunction
What are function procedures commonly known as?
User-Defined Functions (UDFs)
What is the statement used for creating a UDF?
Function UDFName()
Statements
End Function
When creating a UDF what must you always do?
Assign a value, because name of UDF is also name of variable.
What is the statement used for assigning a data type to a UDF?
Function UDFName() As DataType
Where should you generally store a UDF?
Within a standard module
What are the 3 ways you can store a UDF?
- Calling from another procedure.
- Using a UDF in a worksheet/conditional formatting formula.
- Calling UDF from VBE window.
What is difference between a normal UDF and a volatile one?
Volatile functions are recalculated whenever a cell changes.
How do you mark a UDF as volatile?
By setting the Application.Volatile Method to True.
How do you create UDFs that return errors?
Use the CVErr built-in function to convert error numbers to real formula errors.