Sub
Bsp()
Dim
strFilename
As
String
Dim
wks
As
Worksheet
Dim
bool1
As
Boolean
Dim
bool2
As
Boolean
bool1 =
False
bool2 =
False
Set
wks = Worksheets(
"Tabelle1"
)
strFilename = Application.GetOpenFilename(
"Textdateien (*.tra), *.tra"
)
With
Worksheets(
"Tabelle1"
)
With
.QueryTables.Add(
"TEXT;"
& strFilename, Destination:=.Range(
"A2"
))
.TextFilePlatform = 1252
.TextFileColumnDataTypes = Array(1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1)
.RefreshStyle = XlCellInsertionMode.xlOverwriteCells
.TextFileSemicolonDelimiter =
True
Call
.Refresh(BackgroundQuery:=
False
)
Call
.Delete
End
With
End
With
Farbe =
""
Querschnitt =
""
Worksheets(1).
Select
wks.
Select
Range(
"B2"
).
Select
Zeilenanzahl = ActiveSheet.Cells(Rows.Count, 5).
End
(xlUp).Row - 1
For
i = 1
To
Zeilenanzahl
Material = wks.Cells(1 + i, 2)
Worksheets(
"Material"
).
Select
Range(
"B2"
).
Select
Zeilenanzahl2 = ActiveSheet.Cells(Rows.Count, 2).
End
(xlUp).Row - 1
For
j = 1
To
Zeilenanzahl2
If
Material = Worksheets(
"Material"
).Cells(1 + j, 2)
Then
wks.Cells(1 + i, 2) = Worksheets(
"Material"
).Cells(1 + j, 1)
wks.Cells(1 + i, 25) = Worksheets(
"Material"
).Cells(1 + j, 7)
wks.Cells(1 + i, 26) = Worksheets(
"Material"
).Cells(1 + j, 8)
bool1 =
True
End
If
If
bool1 =
False
Then
MsgBox
"Querschnitt fehlt!"
&
" "
& Material
Next
j
Farbe = wks.Cells(1 + i, 1)
Worksheets(
"Material"
).
Select
Range(
"E2"
).
Select
Zeilenanzahl3 = ActiveSheet.Cells(Rows.Count, 2).
End
(xlUp).Row - 1
For
k = 1
To
Zeilenanzahl3
If
Farbe = Worksheets(
"Material"
).Cells(1 + k, 5)
Then
wks.Cells(1 + i, 1) = Worksheets(
"Material"
).Cells(1 + k, 4)
bool2 =
True
End
If
If
bool2 =
False
Then
MsgBox
"Farbe fehlen!"
&
" "
& Farbe
Next
k