What is VBA CBOOL Function
how to use it
To use VBA's CBOOL function you need to understand its syntax and arguments:
- Expression: The expression is the number that you want to convert into a boolean value
Example to use CBOOL Function in VBA
To practically understand how to use VBA CBOOL function, you need to go through the below example where we have written a vba code by using it:
Sub example_CBOOL() Range("B1").Value = CBool(Range("A1")) End Sub
In the above example, we have used the value from the cell A1 where we have a number (3) and then we have used the CBOOL function to convert that value into a boolean and it has returned TRUE in the result.
Below are some important points which you need to take care while using CBOOL function in VBA.
- If the value specified is a value other than a number or a number which can’t be recognized as a number, VBA will return the run-time 13 error.
About the Author
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 ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.