Excel日期格式在运行代码后更改 [英] Excel Date Format changed after running code
本文介绍了Excel日期格式在运行代码后更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行此代码时,将日期格式从 dd:mm:yy
更改为 mm:dd:yy
。
When i am running this code it changes the date format from dd:mm:yy
to mm:dd:yy
.
请给我一些提示。虽然这样做完成了如何保持日期格式?
please give me some tips for this. Although it gets my job done how to keep the date format as it is?
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
推荐答案
-
使用Excel进行设置? 如何将VBA文本框格式化为长日期
And what can the regional setting do to you using Excel? How to Format VBA TextBox To Long Date.
所以如果你没有阅读这些帖子,只需要做一个
日期格式化
。但这是暂时的。如果您需要一次解决问题,您必须执行上述区域设置更改。
So if you haven't read these posts simply do a
date formatting
. But this is temporary. You stil have to do the above regional setting changes if you need to have once for all solution.格式(yourdate,dd:mm: yy)
这篇关于Excel日期格式在运行代码后更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文