help edit code when run office 2016 is cornered in a cell!!!

Nguyen Anh Dung

Board Regular
Joined
Feb 28, 2020
Messages
180
Office Version
  1. 2016
Platform
  1. Windows
i have code as below:
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

1599625314869.png



office 2016 is cornered in a cell

1599625396788.png


Thanks all and Best regards,
Nguyen Anh Dung
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,213,530
Messages
6,114,162
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top