26865
29.11.2022, 09:44
Letzter Versuch meinerseits:
Code:
Option Explicit
Sub Kanten_abziehen()
'Kanten abziehne wenn die Kante stärker als das "Max_Fügemaß" ist oder Platte oder Belag nicht gefügt werden kann
Dim LA As Long
Dim vRetP As Variant
Dim vRetBI As Variant
Dim vRetBA As Variant
Dim Abzugsmaß As Long
With Worksheets("Zwischenablage")
For LA = .Cells(Rows.Count, 5).End(xlUp).Row To 1 Step -1
If Not IsEmpty(.Cells(LA, 3).Value) Then vRetP = Application.IfError(Application.VLookup(.Cells(LA, 3).Value, Range("Lager"), 11, False), "Fehlendes Material")
If Not IsEmpty(.Cells(LA, 9).Value) Then vRetBI = Application.IfError(Application.VLookup(.Cells(LA, 9).Value, Range("Lager"), 11, False), "Fehlendes Material")
If Not IsEmpty(.Cells(LA, 8).Value) Then vRetBA = Application.IfError(Application.VLookup(.Cells(LA, 8).Value, Range("Lager"), 11, False), "Fehlendes Material")
If Left(.Cells(LA, 12).Value, 3) = "KA_" Then
Abzugsmaß = CLng(Mid(.Cells(LA, 12), InStrRev(.Cells(LA, 12), "X") + 1))
If Abzugsmaß > Range("Max_Fügemaß").Value Or vRetP <> "x" Or vRetBI <> "x" Or vRetBA <> "x" Then
.Cells(LA, 19).Value = .Cells(LA, 18).Value - Abzugsmaß
End If
End If
Next LA
End With
End Sub