Falscher Programmcode
mctapt
ich habe folgenden Programmcode:
Private Sub CommandButton1_Click()
Dim i As Single
Dim n As Single
Dim anzahl As Single
For i = 1 To 5
Calculate
n = 1000
anzahl = 50
With Worksheets("DOC")
.Range(.Cells(54, 3), .Cells(n, 3)).Select
Selection.Name = "zeit"
.Range(.Cells(54, 4), .Cells(54 + n, 4 + anzahl)).Select
Selection.Name = "preis"
.Range(.Cells(1057, 4), .Cells(1057 + n, 4 + anzahl)).Select
Selection.Name = "delta"
.Range(.Cells(2062, 4), .Cells(2062 + n, 4 + anzahl)).Select
Selection.Name = "tatsachlier"
.Range(.Cells(3067, 4), .Cells(3067 + n, 4 + anzahl)).Select
Selection.Name = "benotigter"
.Range(.Cells(4072, 4), .Cells(4072 + n, 4 + anzahl)).Select
Selection.Name = "cashflow"
.Range(.Cells(5078, 4), .Cells(5078 + n, 4 + anzahl)).Select
Selection.Name = "fehler"
.Range(.Cells(6088, 4), .Cells(6088 + n, 4 + anzahl)).Select
Selection.Name = "vol"
.Cells(6080, anzahl + 4).Select
Selection.Name = "fehler1"
.Cells(6081, anzahl + 4).Select
Selection.Name = "max1"
.Cells(6082, anzahl + 4).Select
Selection.Name = "min1"
.Cells(6080, 4 + anzahl) = "=mean(fehler)"
.Cells(6081, 4 + anzahl) = "=max(fehler)"
.Cells(6082, 4 + anzahl) = "=min(fehler)"
.Cells(6083, 4 + anzahl) = "=stdev(stabw)"
.Cells(40, 7).Formula = "=mean(fehler1)"
.Cells(41, 7).Formula = "=mean(stabw)"
.Cells(42, 7).Formula = "=mean(min1)"
.Cells(43, 7).Formula = "=mean(max1)"
End With
Cells(40, 6) = "Mean Fehler"
Cells(41, 6) = "Mean Stabw"
Cells(42, 6) = "Mean Max Loss"
Cells(43, 6) = "Mean Max Gain"
Next i
End Sub
In meiner Berechnungen tritt ein Fehler auf und ich bin mir nicht ganz sicher wie ich den fixen muss. anstelle den durchschnittlichen Fehler, Stabw, Max Loss und Max Gain pro Spalte zu berechnen, berechne ich über den gesamten Datenbereich ( .Range(.Cells(5078, 4), .Cells(5078 + n, 4 + anzahl)) ) der fehler zieht sich dann durch das ganze sheet weiter. wie kann ich es machen, dass der durchschnitt pro spalte gerechnet wird und nicht insgesamt?
Beste Grüße
mctapt