将指数格式转换为数字

Convert exponential format into number

在 Excel sheet 单元格中 =326/86400 返回 0.003773148

在 VBA ?326/86400 返回 3.77314814814815E-03

我需要使用 VBA 在单元格中返回的值。

我该怎么做?

使用 NumberFormat 格式化单元格。在此示例中,C2 = 326 和 D2 = 86400。单元格 A1 将显示您的答案 .00373148

Sub CalcWithFormat()
 'You custom VBA calculation
  Range("A1").Formula = "=C2/D2"

 'Format the cell
  Range("A1").NumberFormat = "General"
End Sub

如果您需要将格式应用于整个列,请更改为:

 'Format Range
  Range("A:A").NumberFormat = "General"

如果您需要定义小数位数,您需要这样:

'Format Range
 Range("A:A").NumberFormat = "0.000000000"