将数字转换为文本格式的数字
问题描述:
如何将列中的单元格中的所有数字值转换为文本格式编号?
How can I convert all number value in cell in column to text format number?
我尝试过 = TEXT(A2,A2)
,但不能帮助我。 >
I tried =TEXT(A2,"A2")
but it doesn't help me.
答
这是VBA,因为那是你的标签。
Here is VBA since that was in you tags.
行更改所需的列。
Dim ws1 As Excel.Worksheet
Dim strValue As String
Set ws1 = ActiveWorkbook.Sheets("Sheet3")
Dim lRow As Long
lRow = 1
ws1.Activate
'Loop through and record what is in the columns
Do While lRow <= ws1.UsedRange.Rows.count
'Make sure we have a value to read into our string
If ws1.Range("F" & lRow).Value <> "" Then
'Get the number as a string
strValue = str(Trim(ws1.Range("F" & lRow).Value))
'Format the cell as text
ws1.Range("F" & lRow).NumberFormat = "@"
'Write the string value back to the cell
ws1.Range("F" & lRow).Value = strValue
End If
lRow = lRow + 1
Loop