AW: Berechnungsfrage
18.07.2008 15:56:00
David
Mit einem Makro könnte es so gehen:
Sub kombi()
suchwert = Range("L1").Value
Count = 1
Range("A2:J100").ClearContents
If Cells(1, 1) = 0 Then a1 = 0 Else a1 = 1
If Cells(1, 2) = 0 Then b1 = 0 Else b1 = 1
If Cells(1, 3) = 0 Then c1 = 0 Else c1 = 1
If Cells(1, 4) = 0 Then d1 = 0 Else d1 = 1
If Cells(1, 5) = 0 Then e1 = 0 Else e1 = 1
If Cells(1, 6) = 0 Then f1 = 0 Else f1 = 1
If Cells(1, 7) = 0 Then g1 = 0 Else g1 = 1
If Cells(1, 8) = 0 Then h1 = 0 Else h1 = 1
If Cells(1, 9) = 0 Then i1 = 0 Else i1 = 1
If Cells(1, 10) = 0 Then j1 = 0 Else j1 = 1
For a = 0 To a1
For b = 0 To b1
For c = 0 To c1
For d = 0 To d1
For e = 0 To e1
For f = 0 To f1
For g = 0 To g1
For h = 0 To h1
For i = 0 To i1
For j = 0 To j1
summe = (Cells(1, 1) * a) + (Cells(1, 2) * b) + (Cells(1, 3) * c) + (Cells(1, 4) * d) _
+ (Cells(1, 5) * e) + (Cells(1, 6) * f) + (Cells(1, 7) * g) + (Cells(1, 8) * h) + (Cells(1, 9) * i) + (Cells(1, 10) * j)
If summe = suchwert Then
Count = Count + 1
Cells(Count, 1) = Cells(1, 1) * a
Cells(Count, 2) = Cells(1, 2) * b
Cells(Count, 3) = Cells(1, 3) * c
Cells(Count, 4) = Cells(1, 4) * d
Cells(Count, 5) = Cells(1, 5) * e
Cells(Count, 6) = Cells(1, 6) * f
Cells(Count, 7) = Cells(1, 7) * g
Cells(Count, 8) = Cells(1, 8) * h
Cells(Count, 9) = Cells(1, 9) * i
Cells(Count, 10) = Cells(1, 10) * j
End If
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
End Sub
müsste man allerdings noch ein bißchen hübsch machen (Dim etc.), hab ich mir jetzt mal gespart. Die entsprechenden Zellbezüge müsstest du noch auf deine Verhältnisse anpassen, dann kannst du damit bis zu 10 Zahlen bezüglich ihrer Summen auswerten. Geht auch noch recht flott.
Gruß
David