Cells(i,6).Value gibt 0 obwohl in Zelle Text steht
15.02.2005 12:52:38
Christian
ich habe eine große Datenmenge, von der ich bestimmte Inhalte addieren muss, wenn die Datensätze in einigen Parametern übereinstimmen. Dafür hab ich anliegenden Code geschrieben. Der ist eigentlich ganz einfach. Nur gibt er für jede Cells(i, "egal welche Zahl").Text oder .Value eine 0 zurück, obwohl dass im Datensatz nicht so ist. Mit i hat er kein Problem. Er überspringt mir die If-Schleifen, da ja keine zutrifft, da alle Werte 0 sind. Ich bin da völlig ratlos.
Hier mein Code:
Private Sub CommandButton1_Click()
Dim Zeile
Dim Werte(6) As Long
Dim S As Long
Dim i
Sheets("Daten").Activate
Zeile = ActiveCell.SpecialCells(xlLastCell).Row
For i = 2 To Zeile
Sheets("Daten").Activate
Werte(1) = Cells(i, 8).Value
Werte(2) = Cells(i, 9).Value
Werte(3) = Cells(i, 10).Value
Werte(4) = Cells(i, 11).Value
Werte(5) = Cells(i, 12).Value
Werte(6) = Cells(i, 13).Value
If Cells(i, 5).Text = "Handbuch" Then
If Cells(i, 6).Text = "Deutsch" Then
If Cells(i, 7) = "Chinesisch" Then S = 26
If Cells(i, 7).Text = "Dänisch" Then S = 27
If Cells(i, 7).Text = "Englisch" Then S = 28
If Cells(i, 7).Text = "Estnisch" Then S = 29
If Cells(i, 7).Text = "Finnisch" Then S = 30
If Cells(i, 7).Text = "Flämisch" Then S = 31
If Cells(i, 7).Text = "Französisch" Then S = 32
If Cells(i, 7).Text = "Griechisch" Then S = 33
If Cells(i, 7).Text = "Italienisch" Then S = 34
If Cells(i, 7).Text = "Japanisch" Then S = 35
If Cells(i, 7).Text = "Koreanisch" Then S = 36
If Cells(i, 7).Text = "Lettisch" Then S = 37
If Cells(i, 7).Text = "Litauisch" Then S = 38
If Cells(i, 7).Text = "Niederländisch" Then S = 39
If Cells(i, 7).Text = "NL(BE)" Then S = 40
If Cells(i, 7).Text = "Polnisch" Then S = 41
If Cells(i, 7).Text = "Portugiesisch" Then S = 42
If Cells(i, 7).Text = "Russisch" Then S = 43
If Cells(i, 7).Text = "Schwedisch" Then S = 44
If Cells(i, 7).Text = "Slowakisch" Then S = 45
If Cells(i, 7).Text = "Slowenisch" Then S = 46
If Cells(i, 7).Text = "Spanisch" Then S = 47
If Cells(i, 7).Text = "Tschechisch" Then S = 48
If Cells(i, 7).Text = "Ungarisch" Then S = 49
End If
If Cells(i, 6).Text = "Englisch" Then
If Cells(i, 7).Text = "Chinesisch" Then S = 2
If Cells(i, 7).Text = "Dänisch" Then S = 3
If Cells(i, 7).Text = "Deutsch" Then S = 4
If Cells(i, 7).Text = "Estnisch" Then S = 5
If Cells(i, 7).Text = "Finnisch" Then S = 6
If Cells(i, 7).Text = "Flämisch" Then S = 7
If Cells(i, 7).Text = "Französisch" Then S = 8
If Cells(i, 7).Text = "Griechisch" Then S = 9
If Cells(i, 7).Text = "Italienisch" Then S = 10
If Cells(i, 7).Text = "Japanisch" Then S = 11
If Cells(i, 7).Text = "Koreanisch" Then S = 12
If Cells(i, 7).Text = "Lettisch" Then S = 13
If Cells(i, 7).Text = "Litauisch" Then S = 14
If Cells(i, 7).Text = "Niederländisch" Then S = 15
If Cells(i, 7).Text = "NL(BE)" Then S = 16
If Cells(i, 7).Text = "Polnisch" Then S = 17
If Cells(i, 7).Text = "Portugiesisch" Then S = 18
If Cells(i, 7).Text = "Russisch" Then S = 19
If Cells(i, 7).Text = "Schwedisch" Then S = 20
If Cells(i, 7).Text = "Slowakisch" Then S = 21
If Cells(i, 7).Text = "Slowenisch" Then S = 22
If Cells(i, 7).Text = "Spanisch" Then S = 23
If Cells(i, 7).Text = "Tschechisch" Then S = 24
If Cells(i, 7).Text = "Ungarisch" Then S = 25
End If
End If
If Cells(i, 5).Text = "Onlinehilfe" Then
If Cells(i, 6).Text = "Deutsch" Then
If Cells(i, 7).Text = "Chinesisch" Then S = 76
If Cells(i, 7).Text = "Dänisch" Then S = 77
If Cells(i, 7).Text = "Englisch" Then S = 78
If Cells(i, 7).Text = "Estnisch" Then S = 79
If Cells(i, 7).Text = "Finnisch" Then S = 80
If Cells(i, 7).Text = "Flämisch" Then S = 81
If Cells(i, 7).Text = "Französisch" Then S = 82
If Cells(i, 7).Text = "Griechisch" Then S = 83
If Cells(i, 7).Text = "Italienisch" Then S = 84
If Cells(i, 7).Text = "Japanisch" Then S = 85
If Cells(i, 7).Text = "Koreanisch" Then S = 86
If Cells(i, 7).Text = "Lettisch" Then S = 87
If Cells(i, 7).Text = "Litauisch" Then S = 88
If Cells(i, 7).Text = "Niederländisch" Then S = 89
If Cells(i, 7).Text = "NL(BE)" Then S = 90
If Cells(i, 7).Text = "Polnisch" Then S = 91
If Cells(i, 7).Text = "Portugiesisch" Then S = 92
If Cells(i, 7).Text = "Russisch" Then S = 93
If Cells(i, 7).Text = "Schwedisch" Then S = 94
If Cells(i, 7).Text = "Slowakisch" Then S = 95
If Cells(i, 7).Text = "Slowenisch" Then S = 96
If Cells(i, 7).Text = "Spanisch" Then S = 97
If Cells(i, 7).Text = "Tschechisch" Then S = 98
If Cells(i, 7).Text = "Ungarisch" Then S = 99
End If
If Cells(i, 6).Text = "Englisch" Then
If Cells(i, 7).Text = "Chinesisch" Then S = 52
If Cells(i, 7).Text = "Dänisch" Then S = 53
If Cells(i, 7).Text = "Deutsch" Then S = 54
If Cells(i, 7).Text = "Estnisch" Then S = 55
If Cells(i, 7).Text = "Finnisch" Then S = 56
If Cells(i, 7).Text = "Flämisch" Then S = 57
If Cells(i, 7).Text = "Französisch" Then S = 58
If Cells(i, 7).Text = "Griechisch" Then S = 59
If Cells(i, 7).Text = "Italienisch" Then S = 60
If Cells(i, 7).Text = "Japanisch" Then S = 61
If Cells(i, 7).Text = "Koreanisch" Then S = 62
If Cells(i, 7).Text = "Lettisch" Then S = 63
If Cells(i, 7).Text = "Litauisch" Then S = 64
If Cells(i, 7).Text = "Niederländisch" Then S = 65
If Cells(i, 7).Text = "NL(BE)" Then S = 66
If Cells(i, 7).Text = "Polnisch" Then S = 67
If Cells(i, 7).Text = "Portugiesisch" Then S = 68
If Cells(i, 7).Text = "Russisch" Then S = 69
If Cells(i, 7).Text = "Schwedisch" Then S = 70
If Cells(i, 7).Text = "Slowakisch" Then S = 71
If Cells(i, 7).Text = "Slowenisch" Then S = 72
If Cells(i, 7).Text = "Spanisch" Then S = 73
If Cells(i, 7).Text = "Tschechisch" Then S = 74
If Cells(i, 7).Text = "Ungarisch" Then S = 75
End If
End If
If S <> 0 Then
Sheets("Stat").Activate
Cells(S, 4).Value = Cells(S, 4).Value + Werte(1)
Cells(S, 5).Value = Cells(S, 5).Value + Werte(2)
Cells(S, 6).Value = Cells(S, 6).Value + Werte(3)
Cells(S, 7).Value = Cells(S, 7).Value + Werte(4)
Cells(S, 8).Value = Cells(S, 8).Value + Werte(5)
Cells(S, 9).Value = Cells(S, 9).Value + Werte(6)
End If
Next i
Sheets("Stat").Activate
End Sub