Sub leesin()
richting = 0
'bestand openen
vraag = InputBox("Welk bestand moet verwerkt worden?")
openbest$ = "H:\" & vraag & ".txt"
Workbooks.OpenText Filename:=openbest$, Origin:= _
xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote _
, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:= _
False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
' splits de lijninformatie in 5 kolommen
Cells.Find(What:="========== TRIP GROUP", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
rnr = ActiveCell.Row - 1
lijninfo = "A6:A" & rnr
Range(lijninfo).Select
Selection.TextToColumns Destination:=ActiveCell, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(4, 2), Array(44, 1), Array(48, 2), Array( _
90, 2), Array(150, 9)), TrailingMinusNumbers:=True
ActiveCell.Offset(-1, 0) = "route"
ActiveCell.Offset(-1, 1) = "omschrijving"
ActiveCell.Offset(-1, 2) = "lijn"
ActiveCell.Offset(-1, 3) = "bestemming ri. 1"
ActiveCell.Offset(-1, 4) = "bestemming ri. 2"
lijninfo = "A5:E" & rnr
Range(lijninfo).Columns.AutoFit
' plaats de routeinformatie boven de tabellen
[e1].Select
[e1] = "=COUNTIF(A:A,""########## TRIPS"")"
aantalkeren = [e1].Value
[e1].ClearContents
For keren = 1 To aantalkeren
richting = richting + 1
Cells.Find(What:="########## TRIPS", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
If Left(ActiveCell.Offset(1, 0), 4) <> " " Then ActiveCell.Offset(1, 0).EntireRow.Delete
ActiveCell.Clear
If richting = 1 Then ActiveCell.FormulaR1C1 = "=VLOOKUP(RIGHT(TRIM(R[1]C),4),[COLOR="Red"]lijninfo[/COLOR],4,0)"
If richting = 2 Then ActiveCell.FormulaR1C1 = "=VLOOKUP(RIGHT(TRIM(R[1]C),4),[COLOR="red"]lijninfo[/COLOR],5,0)"
If richting = 2 Then richting = 0
Next keren
[a1].Select
[a1].ColumnWidth = 10
End Sub