Dim
strTextArray()
As
String
Public
Sub
importCSV()
Dim
intFileNumber
As
Integer
Dim
lngRows
As
Long
, lngColumns
As
Long
Dim
strText
As
String
Dim
vntTempArray
As
Variant
Reset
intFileNumber = FreeFile
Open
"C:\Users\Andi\Desktop\Neuer Ordner\Namen2.txt"
For
Input
As
#intFileNumber
Do
Until
EOF(intFileNumber)
Input #intFileNumber, strText
lngRows = lngRows + 1
vntTempArray = Split(strText, vbTab)
If
UBound(vntTempArray) > lngColumns
Then
lngColumns = UBound(vntTempArray)
Loop
Close intFileNumber
ReDim
strTextArray(lngRows - 1, lngColumns)
lngRows = 0
Open
"C:\Users\Andi\Desktop\Neuer Ordner\Namen2.txt"
For
Input
As
#intFileNumber
Do
Until
EOF(intFileNumber)
Input #intFileNumber, strText
lngRows = lngRows + 1
vntTempArray = Split(strText, vbTab)
For
lngColumns = LBound(vntTempArray)
To
UBound(vntTempArray)
strTextArray(lngRows - 1, lngColumns) = vntTempArray(lngColumns)
Next
Loop
Close intFileNumber
For
x = 0
To
UBound(strTextArray, 2)
Call
insertValues(strTextArray(0, x), (x))
Next
End
Sub
Function
insertValues(name
As
Variant
, x
As
Integer
)
Dim
f
As
Integer
Dim
g
As
Integer
Dim
find
As
Range
Set
find = Rows(6).find(what:=name, MatchCase:=
True
)
On
Error
GoTo
Err_NotFound
For
f = 1
To
UBound(strTextArray)
Cells(find.Row + f, find.Column).Value = strTextArray(f, x)
Next
Exit
Function
Err_NotFound:
MsgBox
"Field was not found: "
& name
End
Function