0

我有以前导入 Excel 的数据,并希望将这些数据自动放入正确的格式。

现在我的日期看起来像这样: 28122012 应该是 28.12.2012 我的代码,我把我在网上找到的一些资源放在一起,效果很好,除了一个障碍......它忽略了第 V 列:

   Dim rngS As Range
    For Each rngS In .Range("F:F,U:W").Columns
        rngS.TextToColumns Destination:=rngS.Cells(1, 1),  _ 
DataType:=xlFixedWidth, FieldInfo:=Array(0, 4)
    Next

我不确定它为什么这样做。我已经尝试写出每一列,但不行。V 列保持原样,而它周围的所有内容都已正确格式化。

任何想法为什么会这样?

谢谢!

4

1 回答 1

0

The problem is the field it pastes to is treating the value as numerical.

The only real remedy is to set the type to Text for that and other columns that might have such a date value. Then 01122012 will not lose its starting zero.

Alternatively you could let your follow up code or formula anticipate the missing zeroes and work back to date values using LEFT(), RIGHT() and like functions.

于 2012-11-12T13:37:33.480 回答