Ich wollte auch eigentlich nicht den ganzen Code schreiben weil ich hoffte das Problem durch eine Vereinfachung der For Next Schleifen zu lösen ^^""
Also der Code sieht wie folgend aus:
Sub Berechnung()
Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l%, m%, n%, o%, p%, q%
Dim lz_w%, Anzahl&, Setbonus%, Anzeige%, Speicheranzahl%
Dim ws As Worksheet
Dim ws_w As Worksheet
Dim ws_nw As Worksheet
Dim ws_l As Worksheet
Dim DPS(1 To 10001, 0 To 15) As Single
Dim Tausch As Boolean
Set ws = Worksheets("Eingabe")
Set ws_l = Worksheets("Liste")
If ws.Cells(7, 5).Value = "Ja" Then
Set ws_nw = Worksheets("Non-Weapons H")
Set ws_w = Worksheets("Weapons H")
Else
Set ws_nw = Worksheets("Non-Weapons")
Set ws_w = Worksheets("Weapons")
End If
lz_w = ws_w.Cells(Rows.Count, 1).End(xlUp).Row
Anzahl = 5
DPS(1, 0) = 0
DPS(2, 0) = 0
DPS(3, 0) = 0
DPS(4, 0) = 0
DPS(5, 0) = 0
Speicheranzahl = 10001
Setbonus = 0
On Error Resume Next
For a = 2 To ws.Cells(21, 3).Value
For b = ws.Cells(21, 3).Value + 1 To ws.Cells(22, 3).Value
For c = ws.Cells(22, 3).Value + 1 To ws.Cells(23, 3).Value
For d = ws.Cells(23, 3).Value + 1 To ws.Cells(24, 3).Value
For e = ws.Cells(23, 3).Value + 1 To ws.Cells(24, 3).Value
For f = ws.Cells(24, 3).Value + 1 To ws.Cells(25, 3).Value
For g = ws.Cells(25, 3).Value + 1 To ws.Cells(26, 3).Value
For h = ws.Cells(27, 3).Value + 1 To ws.Cells(28, 3).Value
For i = ws.Cells(28, 3).Value + 1 To ws.Cells(29, 3).Value
For j = ws.Cells(30, 3).Value + 1 To ws.Cells(31, 3).Value
For k = ws.Cells(32, 3).Value + 1 To ws.Cells(33, 3).Value
For l = ws.Cells(33, 3).Value + 1 To ws.Cells(34, 3).Value
For o = ws.Cells(36, 2).Value To ws.Cells(35, 3).Value
For m = ws.Cells(35, 2).Value To ws.Cells(36, 2).Value - 1
If ws.Cells(m, 4).Value "Two-Hand" Then
For n = ws.Cells(26, 3).Value + 1 To ws.Cells(27, 3).Value
If ws_l.Cells(a, 11).Value + ws_l.Cells(b, 11).Value + ws_l.Cells(c, 11).Value + _
ws_l.Cells(d, 11).Value + ws_l.Cells(e, 11).Value + ws_l.Cells(f, 11).Value + ws_l.Cells(g, 11).Value + ws_l.Cells(h, 11).Value + ws_l.Cells(i, 11).Value + ws_l.Cells(j, 11).Value + ws_l.Cells(k, 11).Value + ws_l.Cells(l, 11).Value + ws_l.Cells(m, 11).Value + ws_l.Cells(n, 11).Value + ws_l.Cells(o, 11).Value >= ws.Cells(4, 5).Value Then
If ws_l.Cells(a, 19).Value + ws_l.Cells(b, 19).Value + ws_l.Cells(c, 19).Value + _
ws_l.Cells(d, 19).Value + ws_l.Cells(e, 19).Value + ws_l.Cells(f, 19).Value + ws_l.Cells(g, 19).Value + ws_l.Cells(h, 19).Value + ws_l.Cells(i, 19).Value + ws_l.Cells(j, 19).Value + ws_l.Cells(k, 19).Value + ws_l.Cells(l, 19).Value + ws_l.Cells(m, 19).Value + ws_l.Cells(n, 19).Value + ws_l.Cells(o, 19).Value > DPS(4, 0) Then
DPS(Anzahl, 0) = ws_l.Cells(a, 19).Value + ws_l.Cells(b, 19).Value + ws_l. _
Cells(c, 19).Value + ws_l.Cells(d, 19).Value + ws_l.Cells(e, 19).Value + ws_l.Cells(f, 19).Value + ws_l.Cells(g, 19).Value + ws_l.Cells(h, 19).Value + ws_l.Cells(i, 19).Value + ws_l.Cells(j, 19).Value + ws_l.Cells(k, 19).Value + ws_l.Cells(l, 19).Value + ws_l.Cells(m, 19).Value + ws_l.Cells(n, 19).Value + ws_l.Cells(o, 19).Value
DPS(Anzahl, 1) = g
DPS(Anzahl, 2) = i
DPS(Anzahl, 3) = j
DPS(Anzahl, 4) = a
DPS(Anzahl, 5) = b
DPS(Anzahl, 6) = l
DPS(Anzahl, 7) = f
DPS(Anzahl, 8) = k
DPS(Anzahl, 9) = h
DPS(Anzahl, 10) = c
DPS(Anzahl, 11) = d
DPS(Anzahl, 12) = e
DPS(Anzahl, 13) = m
DPS(Anzahl, 14) = n
DPS(Anzahl, 15) = o
'Setbonus
If Left(ws_l.Cells(g, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(b, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(f, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(j, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(h, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Setbonus >= 2 Then DPS(Anzahl, 0) = DPS(Anzahl, 0) + ws.Cells(5, 5).Value
If Setbonus >= 4 Then DPS(Anzahl, 0) = DPS(Anzahl, 0) + ws.Cells(6, 5).Value
Setbonus = 0
Anzahl = Anzahl + 1
'Ordnen
If Anzahl = Speicheranzahl Then
Do
Tausch = False
For p = 1 To Anzahl - 1
If DPS(p, 0) = ws.Cells(4, 5).Value Then
If ws_l.Cells(a, 19).Value + ws_l.Cells(b, 19).Value + ws_l.Cells(c, 19).Value + _
ws_l.Cells(d, 19).Value + ws_l.Cells(e, 19).Value + ws_l.Cells(f, 19).Value + ws_l.Cells(g, 19).Value + ws_l.Cells(h, 19).Value + ws_l.Cells(i, 19).Value + ws_l.Cells(j, 19).Value + ws_l.Cells(k, 19).Value + ws_l.Cells(l, 19).Value + ws_l.Cells(m, 19).Value + ws_l.Cells(n, 19).Value + ws_l.Cells(o, 19).Value > DPS(4, 0) Then
DPS(Anzahl, 0) = ws_l.Cells(a, 19).Value + ws_l.Cells(b, 19).Value + ws_l.Cells( _
c, 19).Value + ws_l.Cells(d, 19).Value + ws_l.Cells(e, 19).Value + ws_l.Cells(f, 19).Value + ws_l.Cells(g, 19).Value + ws_l.Cells(h, 19).Value + ws_l.Cells(i, 19).Value + ws_l.Cells(j, 19).Value + ws_l.Cells(k, 19).Value + ws_l.Cells(l, 19).Value + ws_l.Cells(m, 19).Value + ws_l.Cells(o, 19).Value
DPS(Anzahl, 1) = g
DPS(Anzahl, 2) = i
DPS(Anzahl, 3) = j
DPS(Anzahl, 4) = a
DPS(Anzahl, 5) = b
DPS(Anzahl, 6) = l
DPS(Anzahl, 7) = f
DPS(Anzahl, 8) = k
DPS(Anzahl, 9) = h
DPS(Anzahl, 10) = c
DPS(Anzahl, 11) = d
DPS(Anzahl, 12) = e
DPS(Anzahl, 13) = m
DPS(Anzahl, 14) = 800
DPS(Anzahl, 15) = o
'Setbonus
If Left(ws_l.Cells(g, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(b, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(f, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(j, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Left(ws_l.Cells(h, 2).Value, 3) = "Set" Then Setbonus = Setbonus + 1
If Setbonus >= 2 Then DPS(Anzahl, 0) = DPS(Anzahl, 0) + ws.Cells(5, 5).Value
If Setbonus >= 4 Then DPS(Anzahl, 0) = DPS(Anzahl, 0) + ws.Cells(6, 5).Value
Setbonus = 0
Anzahl = Anzahl + 1
'Ordnen
If Anzahl = Speicheranzahl Then
Do
Tausch = False
For p = 1 To Anzahl - 1
If DPS(p, 0)
Es gibt 15 Slots mit unterschiedlichen Möglichkeiten diese zu befüllen (Zwischen 5 und 20 Werten pro Slot). Ziel ist es alle Möglichkeiten zu vergleichen und die besten 4 auszugeben.in DPS(Anzahl, 0) wird der Vergleichswert gespeichert und in den restlichen Feldern des Arrays die Information dazu welche Zusammensetzung diesen Wert ergeben hat.
In Einzelschritten funktioniert es leider auch nicht er stürzt mir da genauso ab.