VBA CStr function

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

CStr Function Description

The CStr function converts any variable (number, boolean etc.) to a string variable. This functions achieves a similar result as adding the variable to an empty String (vbNullString).

Syntax

The syntax for the CStr function in VBA is:

Parameters

value
An expression / variable that is to be converted to String data type.

Other Notes

The CStr function can be superseded by a simple string concatenation e.g.:

As you can read here it is recommended to use the vbNullString variable instead of an empty string ” “ for heavy VBA calculations.

Example usage

The CStr function can only be used in VBA code. Let’s look at some CStr function examples:

Simply the best place to learn Excel VBA