1. I have 960 .tur files each containing a single value.
2. The txt files are named as case001.tur, case002.tur,.....,case960.tur
2. I would like to make 10 excel files each containing 8x12 cells/array out of every 96 files over 960 files.
The following scripts are meant to that but with no success.
comments would be appreciated!
2. The txt files are named as case001.tur, case002.tur,.....,case960.tur
2. I would like to make 10 excel files each containing 8x12 cells/array out of every 96 files over 960 files.
The following scripts are meant to that but with no success.
Code:
Sub ReadTextFiles() ' Make reference to library: ' Tools -> References -> Microsoft Scripting Runtime Dim iRow As Integer, iCol As Integer Dim iBooksCounter As Integer, iTextCounter As Integer Dim fso As New FileSystemObject Dim txt As TextStream, aFile As File Dim sContent As String, wkb As Workbook For Each aFile In fso.GetFolder(ThisWorkbook.Path).Files If fso.GetExtensionName(aFile.Name) = "tur" Then If iTextCounter Mod 96 = 0 Or iTextCounter = 0 Then iRow = 1: iCol = 1: iBooksCounter = iBooksCounter + 1 If Not wkb Is Nothing Then With wkb .SaveAs Filename:=ThisWorkbook.Path & "\ExcelFile" & iBooksCounter & ".xls" .Close SaveChanges:=True End With End If Set wkb = Workbooks.Add End If Set txt = fso.OpenTextFile(Filename:=aFile.Path, IOMode:=ForReading) sContent = txt.ReadAll With wkb.Sheets(1) iCol = iCol + 1 If iCol = 13 Then iRow = iRow + 1: iCol = 1 End If .Cells(iRow, iCol) = sContent End With End If Next End Sub