如果我使用Excel打开CSV时间列,则如下所示:
Start time End time
3:22 PM 3:24 PM
3:22 PM 3:25 PM
3:22 PM 3:23 PM
3:23 PM 3:25 PM
3:22 PM 3:23 PM
我创建了一个文件对话框,用于在像这样的全新工作表中打开csv:
'OPEN CSV
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & GetFile, Destination:=Range( _
"$A$2"))
.Name = "SessionDetailReport20180921084657"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
其中GetFile是函数:
Function GetFile() As String
Dim filename__path As Variant
filename__path = Application.GetOpenFilename(FileFilter:="Csv (*.CSV), *.CSV", Title:="Select File To Be Opened")
If filename__path = False Then Exit Function
GetFile = filename__path
End Function
它运作完美,但是时间看起来像这样:
Start time End time
32200 PM 32400 PM
32200 PM 32500 PM
32200 PM 32300 PM
32300 PM 32500 PM
32200 PM 32300 PM
我尝试了从单元格格式到从公式重新创建时间的所有方法,但仍然没有。我该怎么做?非常感谢。