![]() |
Excel 2000 importing huge ASCII files into different sheets
Hello,
I would like to load a big ascii file into Excel and split it into different worksheets within the same workbook. The criteria to split is an empty line with the next line being 1.0 In total the files contains 147 entities. Anybody who could help me with VBA code? -- Goran Stjepanovic IT Consultant KAS IT ServiceDesk ================================================== === When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== === |
Excel 2000 importing huge ASCII files into different sheets
Here's an example:
Sub test() Const cFileName = "C:\T\document.txt" Dim intFreeFile As Integer, strTemp As String, i As Long, wks As Worksheet Dim blnBlankLine As Boolean blnBlankLine = False intFreeFile = FreeFile Open cFileName For Input As #intFreeFile Do Until EOF(intFreeFile) If wks Is Nothing Then Set wks = Worksheets.Add(after:=Worksheets(Worksheets.Count) ) i = 1 End If Line Input #intFreeFile, strTemp If strTemp = "" Then blnBlankLine = True i = i + 1 ElseIf strTemp = "1.0" And blnBlankLine Then Set wks = Nothing blnBlankLine = False i = 1 Else wks.Cells(i, 1).Value = strTemp blnBlankLine = False i = i + 1 End If Loop Close #intFreeFile End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Goran Stjepanovic" wrote in message ... Hello, I would like to load a big ascii file into Excel and split it into different worksheets within the same workbook. The criteria to split is an empty line with the next line being 1.0 In total the files contains 147 entities. Anybody who could help me with VBA code? -- Goran Stjepanovic IT Consultant KAS IT ServiceDesk ================================================== === When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== === |
Excel 2000 importing huge ASCII files into different sheets
Hello,
Thanx but it is not working.... could I send you file so you could try it? -- Goran Stjepanovic ================================================== === When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== === "Rob van Gelder" wrote in message ... Here's an example: Sub test() Const cFileName = "C:\T\document.txt" Dim intFreeFile As Integer, strTemp As String, i As Long, wks As Worksheet Dim blnBlankLine As Boolean blnBlankLine = False intFreeFile = FreeFile Open cFileName For Input As #intFreeFile Do Until EOF(intFreeFile) If wks Is Nothing Then Set wks = Worksheets.Add(after:=Worksheets(Worksheets.Count) ) i = 1 End If Line Input #intFreeFile, strTemp If strTemp = "" Then blnBlankLine = True i = i + 1 ElseIf strTemp = "1.0" And blnBlankLine Then Set wks = Nothing blnBlankLine = False i = 1 Else wks.Cells(i, 1).Value = strTemp blnBlankLine = False i = i + 1 End If Loop Close #intFreeFile End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Goran Stjepanovic" wrote in message ... Hello, I would like to load a big ascii file into Excel and split it into different worksheets within the same workbook. The criteria to split is an empty line with the next line being 1.0 In total the files contains 147 entities. Anybody who could help me with VBA code? -- Goran Stjepanovic IT Consultant KAS IT ServiceDesk ================================================== === When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== === |
All times are GMT +1. The time now is 11:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com