AW: Größten Wert merken und ausgeben
25.07.2016 19:15:01
ViGo
Ok, dann werd ich das so probieren. Kann man mit der Formel auch den zweitgrößten, drittgrößten, viertgrößten und fünftgrößten Wert holen???
Ich hab nun versucht die jeweiligen Nutzwerte in diese ausgeblendete Zele zu schreiben... Aber irgendwie ist mein Code falsch. Es wird gesagt, dass ein "else ohne if" vorliegt! Und ich seh es einfach nicht! Wisst ihr auf die schnelle wo da was zu viel sein soll?
Sub Abgleich_Marktanalyse()
Dim i As Long
Dim letztezeile As Long
Dim eingabe As Variant
Dim a As Variant
Dim b As Variant
Dim c As Variant
Dim d As Variant
Dim e As Variant
Dim f As Variant
Dim g As Variant
Dim h As Variant
letztezeile = Worksheets("Marktanalyse").UsedRange.SpecialCells(xlCellTypeLastCell).Row
eingabe = Worksheets("Auswahl_Parametereingabe_1")
With Worksheets("Marktanalyse")
For i = 3 To letztezeile
' MUSS-Parameter-Abfrage
If _
.Cells(i, 5) = eingabe.Cells(16, 5) And _
.Cells(i, 6) = eingabe.Cells(17, 5) And _
.Cells(i, 7) = eingabe.Cells(18, 5) And _
.Cells(i, 8) = eingabe.Cells(19, 5) And _
.Cells(i, 9) = eingabe.Cells(20, 5) And _
.Cells(i, 10) = eingabe.Cells(21, 5) And _
.Cells(i, 11) = eingabe.Cells(22, 5) And _
.Cells(i, 12) = eingabe.Cells(23, 5) Then
'KANN-Paramter
If .Cells(i, 13) = "erfüllt" Or .Cells(i, 13) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 13) = "indifferent" Or .Cells(i, 13) = "hoch" Then a = 1
ElseIf .Cells(i, 13) = "nicht erfüllt" Or .Cells(i, 13) = "mittel" Then a = 0
End If
If .Cells(i, 14) = "erfüllt" Or .Cells(i, 14) = "sehr hoch" Then b = 2
ElseIf .Cells(i, 14) = "indifferent" Or .Cells(i, 14) = "hoch" Then b = 1
ElseIf .Cells(i, 14) = "nicht erfüllt" Or .Cells(i, 14) = "mittel" Then b = 0
End If
If .Cells(i, 15) = "erfüllt" Or .Cells(i, 15) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 15) = "indifferent" Or .Cells(i, 13) = "hoch" Then a = 1
ElseIf .Cells(i, 15) = "nicht erfüllt" Or .Cells(i, 13) = "mittel" Then a = 0
End If
If .Cells(i, 16) = "erfüllt" Or .Cells(i, 16) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 16) = "indifferent" Or .Cells(i, 16) = "hoch" Then a = 1
ElseIf .Cells(i, 16) = "nicht erfüllt" Or .Cells(i, 16) = "mittel" Then a = 0
End If
If .Cells(i, 17) = "erfüllt" Or .Cells(i, 17) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 17) = "indifferent" Or .Cells(i, 17) = "hoch" Then a = 1
ElseIf .Cells(i, 17) = "nicht erfüllt" Or .Cells(i, 17) = "mittel" Then a = 0
End If
If .Cells(i, 18) = "erfüllt" Or .Cells(i, 18) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 18) = "indifferent" Or .Cells(i, 18) = "hoch" Then a = 1
ElseIf .Cells(i, 18) = "nicht erfüllt" Or .Cells(i, 18) = "mittel" Then a = 0
End If
If .Cells(i, 19) = "erfüllt" Or .Cells(i, 19) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 19) = "indifferent" Or .Cells(i, 19) = "hoch" Then a = 1
ElseIf .Cells(i, 19) = "nicht erfüllt" Or .Cells(i, 19) = "mittel" Then a = 0
End If
If .Cells(i, 20) = "erfüllt" Or .Cells(i, 20) = "sehr hoch" Then a = 2
ElseIf .Cells(i, 20) = "indifferent" Or .Cells(i, 20) = "hoch" Then a = 1
ElseIf .Cells(i, 20) = "nicht erfüllt" Or .Cells(i, 20) = "mittel" Then a = 0
End If
Cells(i, 29) = (a * eingabe.Cells(26, 5) + b * eingabe.Cells(27, 5) + c * eingabe.Cells(28, 5) + _
d * eingabe.Cells(29, 5) + e * eingabe.Cells(30, 5) + f * eingabe.Cells(31, 5) + g * eingabe.Cells(32, 5) + h * eingabe.Cells(32, 5)) / _
(2 * eingabe.Cells(26, 5) + 2 * eingabe.Cells(27, 5) + 2 * eingabe.Cells(28, 5) _
+ 2 * eingabe.Cells(29, 5) + 2 * eingabe.Cells(30, 5) + 2 * eingabe.Cells(31, 5) + 2 * eingabe.Cells(32, 5) + 2 * eingabe.Cells(32, 5))
Else: End If
Next i
End With
End Sub
Vielen Dank für eure Hilfe!
Gruß, ViGo