使用For Next Loop转换超过500行的日期格式 [英] convert a date format for over 500 rows using a For Next Loop
本文介绍了使用For Next Loop转换超过500行的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将列C中的日期(最后一行)从现有格式24/01/2016转换为24.01.2016结果必须是日期格式。
我目前的代码是:
LastRow9 = ws5.Cells(Rows.Count,C)。结束(xlUp).Row
对于X9 = 1 To LastRow9
searchvalue =单元格(X9,C)。值
答案=拆分(searchvalue,/)
ws5.Cells(X9,A)。Value = Answer
ws5.Cells(X9,A)。Value = Format(Answer,dd.mm.yyyy)
下一个X9
我得到的答案是30.12.1899有点偏离
解决方案
尝试更改 Range.NumberFormat属性。
与ws5
pre>
.range(.cells(1, C),.Cells(Rows.Count,C)。End(xlUp))。NumberFormat =dd.mm.yyyy
end with
I need to convert dates (up to last row) in column "C" from the existing format 24/01/2016 to 24.01.2016 The result has to be in date format.
My current code is:
LastRow9 = ws5.Cells(Rows.Count, "C").End(xlUp).Row For X9 = 1 To LastRow9 searchvalue = Cells(X9, "C").Value Answer = Split(searchvalue, "/") ws5.Cells(X9, "A").Value = Answer ws5.Cells(X9, "A").Value = Format(Answer, "dd.mm.yyyy") Next X9
the answer i get is 30.12.1899 a bit off the mark
解决方案Try changing the Range.NumberFormat property.
with ws5 .range(.cells(1, "C"), .Cells(Rows.Count, "C").End(xlUp)).NumberFormat = "dd.mm.yyyy" end with
这篇关于使用For Next Loop转换超过500行的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文