Problem mit Makro
12.09.2004 14:39:57
Claudia
kann mir irgendjemand sagen warum an den unten angezeigten Stellen im Makro Fehler auftauchen. Ich steh momentan ein bißchen auf dem Schlauch.
Danke
Claudia
Sub CARMakro()
Dim i As Integer 'Variablen deklarationen Dim n As Integer Dim XMax As Integer XMax = 6 ' Spalten pro block Dim Blocks As Integer Blocks = 8 n = 0
Dim car1 As Double
Dim car2 As Double
Dim car10 As Double
Dim car20 As Double
Dim j As Integer
Do 'Hauptschleife von XMaxer spalte zu XMaxer spalte
car1 = car2 = car10 = car20 = 0
'Datumssuche
i = 0
Do
i = i + 1
Loop Until (Cells(3, 2 + XMax * n) = Cells(i, 2 + n * XMax))
Dim pos As Integer
pos = 7 + XMax * n
'schleife für car1
j = i - 1
Do
car1 = car1 + CDbl(Cells(j, pos).Value) '< ---fehler
j = j + 1
Loop Until (j = i + 2)
'schleife für car2
j = i - 2
Do
car2 = car2 + CDbl(Cells(j, pos).Value) '< --f
j = j + 1
Loop Until (j = i + 3)
'schleife für car10
j = i - 10
Do
car10 = car10 + CDbl(Cells(j, pos).Value) '< ---f
j = j + 1
Loop Until (j = i + 11)
'schleife für car20
j = i - 20
Do
car20 = car20 + CDbl(Cells(j, pos).Value) '< --f
j = j + 1
Loop Until (j = i + 21)
'----Ausgabe---
Cells(334, 2 + XMax * n) = "CAR(-1;1)"
Cells(335, 2 + XMax * n) = "CAR(-2;2)"
Cells(336, 2 + XMax * n) = "CAR(-10;10)"
Cells(337, 2 + XMax * n) = "CAR(-20;20)"
Cells(334, 3 + XMax * n).Value = car1
Cells(335, 3 + XMax * n).Value = car2
Cells(336, 3 + XMax * n).Value = car10
Cells(337, 3 + XMax * n).Value = car20
n = n + 1
Loop Until (n = Blocks)
End Sub