VBA CStr function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

CStr Function Description

The CStr function converts any variable to a string variable.


The syntax for the CStr function in VBA is:

CStr( expression )


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.:

CStr 21123
'Result: "21123" (String)

"" & 21123
'Result: "21123" (String)

Example usage

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

CStr 12345
'Result: "12345" (String)

Dim tmp as Long
tmp = 10
CStr tmp
'Result: "10" (String)

Simply the best place to learn VBA!