mit Hilfe von UweD habe ich mir eine Lösung zusammengebaut. Allerdings habe ich das Problem, dass VLOOKUP nicht wie gewünscht funktioniert (einfach nicht bei ELSE weitermacht, obwohl es mit vlookup als normale Formel funktionier) und die Vergleichswerte in einer anderen Tabelle nicht findet:
Die Zellen sind in beiden Tabellen als "General" formatiert.
Sub TestFinal()
ActiveWorkbook.Activate
Sheets("SHEET1").Select
With Sheets("SHEET1")
Dim i&, LR&
LR = .Cells(.Rows.Count, "A").End(xlUp).Row 'letzte Zeile der Spalte
Range("B1") = InputBox("Bitte tätigen Sie eine Eingabe", "Feld1", Range("B1"))
Range("B5") = InputBox("Bitte tätigen Sie eine Eingabe", "Feld2", Range("B5"))
Range("B2") = "31.12.2016"
For i = 8 To LR
If .Cells(i, 1) "" And .Cells(i, 5) "-" And .Cells(i, 5) "" Then
.Cells(i, 9) = IIf(.Cells(i, 3) 0, "Nein", "")
.Cells(i, 10) = IIf(.Cells(i, 3) 0, "Nein", "")
.Cells(i, 11) = IIf(.Cells(i, 3) 0, "Nein", "")
.Cells(i, 12) = IIf(Abs(.Cells(i, 3)) >= .Cells(5, 2), "Ja", "Nein")
On Error Resume Next
If .Cells(i, 12) = "Nein" Then
.Cells(i, 14) = "Nein"
Else
If IsError(WorksheetFunction.VLookup(Cells(i, 1).Value, Workbooks(" _
COMPARE.xlsx").Worksheets("Sheet1").Range("A2:C50"), 3, False)) Then
.Cells(i, 13).Value = .Cells(i, 1).Value
Else
.Cells(i, 13) = WorksheetFunction.VLookup(Cells(i, 1).Value, _
Workbooks("COMPARE.xlsx").Worksheets("Sheet1").Range("A2:C50"), 3, False)
.Cells(i, 2) = WorksheetFunction.VLookup(Cells(i, 1).Value, _
Workbooks("COMPARE.xlsx").Worksheets("Sheet1").Range("A2:C50"), 2, False)
End If
End If
End If
Next
End With
With Sheets("SHEET2").Select
Range("H8:K19") = "Nein"
Range("K8") = "Ja"
Range("K15") = "Ja"
Range("K18") = "Ja"
Range("K19").Select
End With
Sheets("SHEET1").Select
End Sub