Option
Explicit
Private
Sub
CommandButton1_Click()
Dim
lngZeile
As
Long
Dim
lngZeileZiel
As
Long
Dim
WO
As
String
Dim
rngWO
Dim
oCol
As
Long
Dim
myCell
Dim
mycellx
Dim
x
As
Long
Dim
nextRow
As
Long
Workbooks(
"Produktionsplan.xlsx"
).Activate
Worksheets(
"RS2"
).Activate
lngZeile = ActiveSheet.Cells(Rows.Count, 2).
End
(xlUp).Row
lngZeileZiel = Workbooks(
"FW.xlsx"
).Worksheets(
"Sheet1"
).Cells(Rows.Count, 1).
End
(xlUp).Row
For
x = lngZeile
To
2
Step
-1
WO = ActiveSheet.Cells(x, 2).Value
If
Application.WorksheetFunction.CountIf(Workbooks(
"A.xlsm"
).Worksheets(
"PartsData"
).Columns(
"U"
), WO) = 0
Then
lngZeileZiel = lngZeileZiel + 1
Workbooks(
"Produktionsplan.xlsx"
).Worksheets(
"RS2"
).Rows(x).Copy _
Destination:=Workbooks(
"FW.xlsx"
).Worksheets(
"Sheet1"
).Cells(lngZeileZiel, 1)
End
If
Next
x
End
Sub