Nguyen Anh Dung
Board Regular
- Joined
- Feb 28, 2020
- Messages
- 180
- Office Version
- 2016
- Platform
- Windows
i have code as below:
when i run with office 2016 then cornered in a cell. But run with Office 2019 ok.
office 2019 run ok
office 2016 is cornered in a cell
Thanks all and Best regards,
Nguyen Anh Dung
when i run with office 2016 then cornered in a cell. But run with Office 2019 ok.
Code:
Sub EditGarmin()
Dim FolderPath As String, FilePath As String, NewFileName As String
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "CSV (MS-DOS)", "*.csv"
If .Show Then
FolderPath = FSO.GetParentFolderName(.SelectedItems(1)) & "\"
For i = 1 To .SelectedItems.Count
FilePath = .SelectedItems(i)
NewFileName = FSO.GetBaseName(FilePath)
NewFileName = Left(NewFileName, Len(NewFileName)) & "_N.csv"
FSO.CopyFile FilePath, FolderPath & NewFileName, True
CSVAmend2 FolderPath, NewFileName
Next
End If
MsgBox "Ho" & ChrW(224) & "n Th" & ChrW(224) & "nh !!!"
End With
End Sub
Sub CSVAmend2(FolderPath As String, FileName As String)
Dim wb As Workbook, ws As Worksheet, rng As Range
Set wb = Workbooks.Open(FolderPath & FileName)
Set ws = wb.Sheets(1)
Application.DisplayAlerts = False
Columns("F").Replace What:="T0", Replacement:=" 0"
Columns("F").Replace What:="Z", Replacement:=""
wb.Worksheets(1).Columns("f:f").NumberFormat = "yyyy-mm-dd hh:mm:ss"
'ws.Range("A1:AE46").SpecialCells(xlCellTypeVisible).Delete
Rows("1:" & Columns(2).Find("trksegID").Row - 1).Delete
'ws.Range("G47:Z47").EntireColumn.Delete
ws.Range("G:Z").EntireColumn.Delete
Sheets(1).Cells(1, 7).Value = "time_n"
Set rng = ws.Range("F2", ws.Range("F" & ws.Rows.Count).End(xlUp))
With rng.Offset(, 1)
.Formula = "=F2+ TIME(7,0,0)"
.Value = .Value
.Offset(, 0).Value = .Value
.Offset(, 0).NumberFormat = "yyyy-mm-dd hh:mm:ss"
End With
'ws.Range("F2:F65000").Copy
'ws.Range("G2:G65000").PasteSpecial xlPasteFormulas
'wb.Worksheets(1).Columns("G:G").NumberFormat = "yyyy-mm-dd hh:mm:ss"
Application.DisplayAlerts = True
wb.Close SaveChanges:=True
End Sub
office 2019 run ok
office 2016 is cornered in a cell
Thanks all and Best regards,
Nguyen Anh Dung