VBA CVERR Function

HomeVBA Functions LIST (Category Wise)How to use the VBA CVERR Function (Syntax + Example)

What is VBA CVERR Function

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 errors code from here.

how to use it

To use VBA's CVERR function you need to understand its syntax and arguments:

Syntax

CVErr(Expression)

Arguments

  • Expression: The error code for which you want to know the error data type.

Example to use CVERR Function in VBA

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

Notes

Below are some important points which you need to take care while using CVERR function in VBA.

  • If the argument which you have defined as an error code is not an error code and other than a number, VBA will return the run-time 13 error.
  • And if the argument which you have defined is a number but not an error code, VBA will return run-time 5 error. 

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.