首页 > 解决方案 > 将数字从科学记数法转换为文本

问题描述

我尝试了很多方法(.numberformats 等),我无法将这些科学数字(列 [A])转换为文本,以便正确显示 EAN 代码(列 [B])。

我需要一个 VBA 解决方案。

有什么建议么?

在此处输入图像描述

编辑:对我有用的解决方案,但我不满意:

For i = 1 To ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    Range("A" & i).NumberFormat = "@"
    Range("A" & i) = Trim(Range("A" & i))
Next i

这将直接将列 [A] 转换为正确的格式。

标签: excelvba

解决方案


Dim iRowCount As Integer

iRowCount = Cells(Rows.Count, "A").End(xlUp).Row

Range("B2:B" & iRowCount).Value = Range("A2:A" & iRowCount).Value
Range("B2:B" & iRowCount).NumberFormat = "0"

推荐阅读