Array-Problem?
20.01.2009 13:45:13
Petra
hier ein kurzer Beispielcode:
Sub sum_man()
Dim lRow, Z
Dim LR
Dim a As Integer
Dim SP1, SP2, SP3 '.usw....bis ca. SP50.
nrech = True
With ActiveSheet
a = .Cells.Find(What:="summe gesamt", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
lRow = a - 2
For Z = lRow To 4 Step -1
If UCase(Cells(Z, 4)) = UCase(Cells(Z - 1, 4)) Then
SP1 = SP1 + Cells(Z, 28)
SP2 = SP2 + Cells(Z, 29)
SP3 = SP3 + Cells(Z, 30)
Else
Rows(Z).Insert Shift:=xlDown
Cells(Z, 4) = "ZW"
SP1 = SP1 + Cells(Z + 1, 28)
Cells(Z, 28) = SP1
SP1 = 0
SP2 = SP2 + Cells(Z + 1, 29)
Cells(Z, 29) = SP2
SP2 = 0
SP3 = SP3 + Cells(Z + 1, 30)
Cells(Z, 30) = SP3
SP3 = 0
'usw. bis SP50
End If
Next Z
End With
nrech = False
End Sub
Mein Problem: wie kann ich die "Z"-Schleife in ein Array packen, damit das Ganze kürzer wird?
Vielen Dank für Eure Beiträge
Liebe Grüße Petra