Hello experts,

I gues for you easy topic - could you please help me to update below written code:

Variant 1:
specific csv file name open with StrPath - for example open "data.csv" in C:\Users\Documents\ (not GetOpenbyFileName), the rest code same

Variant 2:
add to code method to find "the freshest" csv file in specific folder, (for example C:\Users\Documents\) and give data from file, the rest code same

THANK YOU VERY MUCH. Have a nice day.
vendam

Sub test()
    Dim fn As String, txt As String, x, y, n As Long
    Dim myCols, colRef, i As Long, ii As Long
    fn = Application.GetOpenFilename("CSVFies,*.csv")
    If fn = "False" Then Exit Sub
    myCols = Array("FEATURE CODE", "Point_ID", "Easting", "Northing", "ELEVATION", "Remark1")
    x = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll, vbCrLf)
    colRef = Filter(WorksheetFunction.IfError(Application.Match(myCols, Split(x(0), ","), 0), False), False, 0)
    ReDim a(1 To UBound(x) + 1, 1 To UBound(colRef) + 1)
    For i = 0 To UBound(x)
        If x(i) <> "" Then
            y = Split(x(i), ","): n = n + 1
            For ii = 0 To UBound(colRef)
                a(i + 1, ii + 1) = y(colRef(ii) - 1)
            Next
        End If
    Next
    Range("a2").Resize(n, UBound(a, 2)).Value = a
End Sub