Got any Excel/VBA Questions? Free Excel Help
The example below shows how CStr can be used in Excel VBA to convert to a String data type. Returns for CStr depend on the expression argument... Boolean = A string containing True or False. Date = A string containing a date in the short date format of your system. Null = A run-time error. Empty = A zero-length string (""). Error = A string containing the word Error followed by the error number. Other numeric = A string containing the number.
Sub ConvertToString() Dim vStr vStr = 10000 MsgBox IsNumeric(strNum) MsgBox IsNumeric(CStr(strNum)) End Sub
See also:
Convert Excel Text To Upper Case |
Excel VBA: Convert to a Variant Data Type |
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.