Site icon Excel Champs

VBA CVERR Function (Syntax + Example)

The VBA CVERR function is listed under the vba error handling category of VBA functions. When you use it in a VBA code, it returns an error data type according to the code you specify. In simple words, with CVERR you can get an error type in the result. Check out these error codes from here.

Syntax

CVErr(Expression)

Arguments

Example

To practically understand how to use the VBA CVERR function, you need to go through the below example where we have written a vba code by using it:

In the above code, we have used CVERR and the IF condition with it to test, where it checks if the value in cell A2 is zero or not, and if it is, we have supplied error code 11 (11 is the error data type which represents a division by zero) to the function to return the error data type.

Notes

Exit mobile version