VBA Str function – How to convert a number to text

Last Updated on January 11, 2023 by token

1. Str VBA function – Description

The VBA Str function   converts a numeric value to the String data type  . The simplest form of the String data type with a variable number of characters takes up as many bytes in memory as there are characters in a given text string.

2. VBA Str function – Syntax

Str (Number)

Number : Any numeric value in the numeric data type.

Function return : String / text value.

3. VBA Str function – Example

How to use Str function   in VBA Excel? Below are examples of using the Str function   in the VisualBasic Editor.

Example 1:  Converting a number to a String type. Str – VBA function example. The result in the MsgBox window.

Dim intNumber As Integer
Dim StrNumber As String
intNumber = 3200
StrNumber = Str (intNumber)
MsgBox "The number is:" & StrNumber

Example 2:  Converting a number to a String type. VBA Str – function example. The result in a sheet cell.

Dim intNumber2 As Integer
Dim StrNumber2 As String
intNumber2 = 3200
StrNumber2 = Str (intNumber2)
Range ("A1") = "The number is:" & StrNumber2
Excel VBA Functions - VBA Str function
Excel VBA Functions – VBA Str function

4. VB Str function – Additional information

  • none

5. Str function VisualBasic – Where to use?

The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.

The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address:  VBA functions .

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: