Convert numbers to text
To convert numbers to text you need to apply the Excel TEXT function
Example: Convert numbers to text
=TEXT(B5,"0")
|
The formula uses the Excel TEXT function to convert the number in cell B5 to text. Therefore, if you were to copy the result (cell C5) and paste values the number will be formatted as text.
|
Sub Convert_numbers_to_text()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to convert the number in cell ("B5") to text
ws.Range("C5") = Application.WorksheetFunction.Text(ws.Range("B5"), "'0")
ws.Range("C5") = Application.WorksheetFunction.Text(ws.Range("B5"), "'0")
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analyst.
Number to convert to Text: Ensure that the number that you want to convert to text is captured in cell ("B5").
Worksheet Name: Have a worksheet named Analyst.
Number to convert to Text: Ensure that the number that you want to convert to text is captured in cell ("B5").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Number to convert to Text: Select the number that you want to convert to text by changing the cell reference ("B5") to any cell in the worksheet that contains the number that you want to convert to text and doesn't conflict with the formula.
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Number to convert to Text: Select the number that you want to convert to text by changing the cell reference ("B5") to any cell in the worksheet that contains the number that you want to convert to text and doesn't conflict with the formula.
EXPLANATION
To convert numbers to text you need to apply the Excel TEXT function.
To convert numbers to text you need to apply the Excel TEXT function.
FORMULA
=TEXT(number, format_text)
=TEXT(number, format_text)
ARGUMENTS
number: A numeric value to to convert to a specified text format.
format_text: The format that will be applied against the selected value.