Clarification of Question by
lochness-ga
on
29 Oct 2003 23:43 PST
Sorry to close this question. I kinda need the answer to prepare my
quarterly taxes so I had to write it myself to run in Excel. Not
elegant but does the job. Thanks everyone!
Sub doit()
'Please change file name and path
csvName = "C:\finance\data.TXT"
i = 1
j = 1
rw = 1
Application.ScreenUpdating = False
momax = 31
'3 months: Jul, Aug, sept
For q = 1 To 3
If q = 3 Then momax = 30
For numdays = 1 To momax
If numdays <= 9 Then
sNumDay = "0" & numdays
Else
sNumDay = numdays
End If
If q = 1 Then sMonth = "07"
If q = 2 Then sMonth = "08"
If q = 3 Then sMonth = "09"
'data is stored in a zip file. Unzip and data.txt can be seen
sfile = "pkunzip.exe -o c:\finance\" & sMonth & "-" & sNumDay &
"-03.zip c:\finance"
Shell sfile
'wait 1 sec
Application.Wait Now + TimeValue("00:00:01")
j = 1
i = 1
Open csvName For Input As #1 'was unzipped above
Do Until EOF(1)
Line Input #1, tmpline
field = Replace(tmpline, " ", "")
If (i = 5 Or i = 11 Or i = 12 Or i = 23 Or i = 24 Or i = 30 Or i = 31)
Then
If i = 5 Then
field = Replace(field, "|", "")
End If
If i = 11 Then
field = Right(field, Len(field) - 7)
End If
If i = 12 Then
field = Right(field, Len(field) - 8)
End If
If i = 23 Then
field = Right(field, Len(field) - 7)
End If
If i = 24 Then
field = Right(field, Len(field) - 8)
End If
If i = 30 Then
field = Right(field, Len(field) - 7)
End If
If i = 31 Then
field = Right(field, Len(field) - 8)
End If
Worksheets("Sheet1").Activate
Range(Cells(rw, j), Cells(rw, j)).FormulaR1C1 = field
j = j + 1
End If
i = i + 1
Loop
Close #1
rw = rw + 1
Next
Next
Application.ScreenUpdating = True
End Sub