下面的代码只是复制和粘贴日期,通常采用mm / dd / yy格式,但可以是任何日期。
WB1.Worksheets("WS1").Range(Cells(3, "g"), Cells(RowCountOPR, "g")).Copy
WB2.Worksheets("WS2").Cells(RowCountTrack, "c").PasteSpecial
WB2.Worksheets("WS2").Cells(RowCountTrack, "n").PasteSpecial
WB2.Worksheets("WS2").Cells(RowCountTrack, "t").PasteSpecial
我希望它在“c”列中粘贴yyyymmdd的格式。如何在此处添加格式?我可以吗?
答案 0 :(得分:0)
只需添加一些更改单元格格式的行:
WB1.Worksheets("WS1").Range(Cells(3, "g"), Cells(RowCountOPR, "g")).Copy
WB2.Worksheets("WS2").Cells(RowCountTrack, "c").PasteSpecial
WB2.Worksheets("WS2").Cells(RowCountTrack, "n").PasteSpecial
WB2.Worksheets("WS2").Cells(RowCountTrack, "t").PasteSpecial
WB2.Worksheets("WS2").Cells(RowCountTrack, "c").NumberFormat = "yyyymmdd"
WB2.Worksheets("WS2").Cells(RowCountTrack + 1, "c").NumberFormat = "yyyymmdd"