Excel 2000 importing huge ASCII files into different sheets

G

Goran Stjepanovic

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.
=====================================================
 
R

Rob van Gelder

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
 
G

Goran Stjepanovic

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.
=====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top