Now let us convert the very basic data type which is an integer in the same way above. Follow the below steps to use CSTR function in Excel VBA.
Though A had a Boolean value in it we converted it to String using the CSTR function.
Now let us see the data type for variable B. The value stored in B is the value of A which is “TRUE”. Step 9: Re-run the above code and see the last two result as follows. Step 8: Now display both the data type of variable B and the value stored in B using the message box function as follows. We defined another variable and store the value of A converting it to a string using CSTR function. Step 7: Right now the data type for the variable A is Boolean now let us change it to a string using VBA CSTR function as follows. Step 6: Run the code by hitting F5 or Run button and see the output. Step 5: Let us first display the data type of the variable A using the TypeName Function as follows. Step 4: Declare a variable as data type as Boolean and store value true in it. Step 3: Double click on the module and let’s begin our macro with a name as shown below. Step 2: In the VBA editor insert a module from the reference to the screenshot below.