vrijdag 8 mei 2009

Tekst conversie in Excel

Sub Import()
Open "d:\data.txt" For Input As #1
R = 1
While Not EOF(1) 'Scan file line by line
C = 1
Entry = ""
Line Input #1, Buffer
Length = Len(Buffer)
i = 1
While i <= Length 'split comma-delimited string into cells
If (Mid(Buffer, i, 1)) = "," Then
With Application.Cells(R, C)
.NumberFormat = "@" 'Text formatting
.Value = Entry
End With
C = C + 1
Entry = ""
Else
Entry = Entry + Mid(Buffer, i, 1)
End If
i = i + 1
Wend
If Len(Entry) > 0 Then
With Application.Cells(R, C)
.NumberFormat = "@" 'Text formatting
.Value = Entry
End With
End If
R = R + 1
Wend
Close #1
End Sub

Geen opmerkingen: