Got any Excel/VBA Questions? Free Excel Help.
The example below shows how CBool can be used in Excel VBA to convert a string or number to a Boolean (TRUE/FALSE)
Sub ConvertToBoolean() Dim lNum As Integer Dim strText As String lNum = 0 MsgBox CBool(lNum) lNum = 1 'Or higher MsgBox CBool(lNum) strText = "A" MsgBox CBool(strText = "B") MsgBox CBool(strText <> "B") End Sub
See also:
Free Training Course: Lesson 1 - Excel Fundamentals
See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.