我所拥有的以下代码基本上格式化了交易行的Col J:J。对于DD-MM-YY,日期格式显示为MM-DD-YY美式格式,有更好的方法来确保它始终为DD-MM-YY
Sub Formatdate()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim sPath As String, sFile As String
Dim wb As Workbook
Dim wbname As String
wbname = "Transactions.csv"
sPath = "\\Csdatg04\psproject\Robot\Project Preload\Transactions\Robot WIP\"
sFile = sPath & "Transactions.csv"
Set wb = Workbooks.Open(sFile)
Workbooks(wbname).Worksheets(1).Range("J:J").EntireColumn.NumberFormat = "DD-MM-YYYY"
Workbooks(wbname).Close True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub