AW: 2 Versuch
26.04.2005 21:08:23
Christoph
Hallo Peter,
so ganz hab ich noch nicht verstanden, warum das bei dir nicht funktionieren sollte. Bei mir verhält sich der Code wie erwartet (Beschreibung zu LCase s.o.)
ich hab die Formeln noch auf die nächsten zwei Spalten erweitert, sowie das akt. Datum in die Zelle "Abrechnung" integriert.
Hoffe, du kommst damit klar...
Option Explicit
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
Dim tRow As Long, n As Integer
Dim arrSheets As Variant
'Tabellennamen - anpassen!
arrSheets = Array("Jan", "Feb.", "Mär", "Apr", "Mai", "Jun", "Jul", _
"Aug", "Sep", "Okt", "Nov", "Dez")
For n = 0 To 11
If sh.Name = arrSheets(n) Then
If Target.Column = 5 And Target.Row > 12 And Target.Count = 1 Then
On Error GoTo ERRORHANDLER
Application.EnableEvents = False
If LCase(Target) Like "*abrechnung*" Then
Target = "Abrechnung " & Format(Date, "DD.MM.YYYY")
tRow = Target.Row - 1
Target.Offset(0, 1).Formula = _
"=SUM(" & Range(Cells(13, 6), Cells(tRow, 6)).Address & ")+" & _
"(SUM(" & Range(Cells(13, 7), Cells(tRow, 7)).Address & ")-" & _
"MOD(SUM(" & Range(Cells(13, 7), Cells(tRow, 7)).Address & "), 100))/100"
Target.Offset(0, 2).Formula = _
"=MOD(SUM(" & Range(Cells(13, 7), Cells(tRow, 7)).Address & "), 100)"
Target.Offset(0, 3).Formula = _
"=SUM(" & Range(Cells(13, 8), Cells(tRow, 8)).Address & ")+" & _
"(SUM(" & Range(Cells(13, 9), Cells(tRow, 9)).Address & ")-" & _
"MOD(SUM(" & Range(Cells(13, 9), Cells(tRow, 9)).Address & "), 100))/100"
Target.Offset(0, 4).Formula = _
"=MOD(SUM(" & Range(Cells(13, 9), Cells(tRow, 9)).Address & "), 100)"
End If
makeFrame Target.Row, sh
End If
Exit For
End If
Next
ERRORHANDLER:
Application.EnableEvents = True
End Sub
Gruß
Christoph