Re: Forum
12.04.2003 18:52:04
Christian
Hi ich bin`s nochmalalso habe es jetzt soweit fertig. getestet habe ich es noch nicht. Muß ich jetz vor jeder Anwahl einer Zellel auch ActiveSheet schreiben???
Sub NeueAR()
Dim AnzahlAR
Dim Formel1, Formel2
Dim j, i
Dim LZ, LS
'ActiveSheet
i = 20
LS = Cells(Columns.count, 1).End(xlUp).Columns 'liefert die letzte belegte Spalte der Tabelle
LZ = Cells(Rows.count, 1).End(xlUp).Rows 'liefert die letzte belegte Zeile der Tabelle
For i = 20 To LS Step 1
If Cells(4, i) = "Gesamt" Then
Columns(i - 2, i - 1).Copy
Columns(i).Insert Shift:=xlToRight
AnzahlAR = (i - 16) / 2 'ermittelt die Anzahl der bereits vorhandenen AR`s
Cells(4, i + 4).Value = AnzahlAR + 1 & ".AR"
Cells(5, i + 5).Value = AnzahlAR + 1 & ".Aufmass"
Formel1 = Cells(10, i + 2).Formula
Formel2 = Cells(10, i + 3).Formula
For j = 7 To LZ - 12 Step 1
If Cells(j, i + 1).Value <> "" And Cells(j, i + 1).Interior.ColorIndex <> 15 Then
Cells(j, i + 4).Formula = Formel1 & "+" & CStr(i) & j
Cells(j, i + 5).Formula = Formel2 & "+" & CStr(i) & j
End If
Next j
End If
Next i
End Sub