Run this macro in the uploaded file ( remember to change the file path and name to suit )
Then save the file and return it to me
Code:Sub OpenSample2_csv_8June() ' Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1) Dim FilePathandName As String Let FilePathandName = ThisWorkbook.Path & Application.PathSeparator & "Sample2.csv" ' ' CHANGE TO SUIT Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function Dim RwCnt As Long, TextFileLineIn As String Open FilePathandName For Input As #FileNum 'Open Route to data Do While Not EOF(FileNum) Line Input #FileNum, TextFileLineIn Let Ws1.Range("A" & Ws1.Range("A" & ActiveSheet.Rows.Count & "").End(xlUp).Row + 1 & "").Value = Left(TextFileLineIn, 4) Let Ws1.Range("B" & ActiveSheet.Range("B" & Ws1.Rows.Count & "").End(xlUp).Row + 1 & "").Value = Len(TextFileLineIn) Loop Close #FileNum End Sub
Test2csvContents.xls : https://app.box.com/s/2knx1msb84ga5phpictm0c6bjcdnai6f




Reply With Quote

Bookmarks