运行代码后,Excel日期格式已更改

时间:2013-01-09 05:49:48

标签: vba date

当我运行此代码时,它会将日期格式从dd:mm:yy更改为mm:dd:yy

请给我一些提示。虽然我的工作完成了如何保持日期格式不变?

Sub copyAllselectedWbtoSheets()
Set destWB = ActiveWorkbook
Dim DestCell As Range
FileNames = Application.GetOpenFilename( _
        filefilter:="Excel Files (*.csv*),*.csv*", _
        Title:="Select the workbooks to load.", MultiSelect:=True)
If IsArray(FileNames) = False Then
    If FileNames = False Then
        Exit Sub
    End If
End If
For N = LBound(FileNames) To UBound(FileNames)
    Set wb = Workbooks.Open(fileName:=FileNames(N), ReadOnly:=True)
    With wb
      .Sheets(1).Copy After:=destWB.Sheets(destWB.Sheets.Count)
      ActiveSheet.Name = Replace(wb.Name, ".csv", "ABC") 'Name sheet
      .Close True
    End With
Next N
End Sub

1 个答案:

答案 0 :(得分:0)

因此,如果您还没有阅读这些帖子,只需执行date formatting即可。但这是暂时的。如果您需要一次性解决所有问题,您必须进行上述区域设置更改。

Format(yourdate, "dd:mm:yy")