Mehrere Worksheet_Change-Ereignisse?
10.11.2003 14:20:35
Benni
Hab ein Problem mit meinem Protokoll welches ich über worksheet_change erstelle:
Private Sub worksheet_change(ByVal target As Range)
'Änderung der Maschinenzahl bis ans Ende der Tabelle übernehmen und neuen Wert ins Protokoll übernehmen
Dim r1 As Range
Dim r2 As Range
Dim rGes As Range
Dim Neuwert As Variant
Dim spalte As Integer
Dim Reihe As Integer
If Intersect(target, Range("c4:aq13")) Is Nothing Then Exit Sub ' GoTo _Aenderung
Neuwert = target.Value
Application.EnableEvents = False
On Error GoTo errorhandler
Reihe = target.Row
spalte = target.Column
Worksheets("Maschinenzahlen").Activate
For i = spalte To 43
Cells(Reihe, i).Value = Neuwert
Next i
With Worksheets("Protokoll")
irow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Unprotect password:=""
If irow > 200 Then
.Rows(3).EntireRow.Delete shift:=xlUp
irow = 200
End If
.Cells(irow, 1).Value = target.Address(False, False)
.Cells(irow, 2).Value = "Maschinenzahlen"
.Cells(irow, 3).Value = "geändert auf:"
.Cells(irow, 4).Value = Neuwert
.Cells(irow, 5).Value = Date
.Cells(irow, 6).Value = BenutzerName1
.Protect password:=""
End With
'Aenderung:
' Dim vNew As Variant, vold As Variant
' Dim irow As Integer
' If Intersect(Target, Range("A15:aq50")) Is Nothing Then Exit Sub
' vNew = Target.Value
' Application.EnableEvents = False
' On Error GoTo ErrorHandler
' Application.Undo
' vold = Target.Value
' Target.Value = vNew
' With Worksheets("Protokoll")
' irow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
' .Unprotect Password:=""
' .Cells(irow, 1).Value = Target.Address(False, False)
' .Cells(irow, 2).Value = "Maschinenzahlen"
' .Cells(irow, 3).Value = vold
' .Cells(irow, 4).Value = vNew
' .Cells(irow, 5).Value = Date
' .Cells(irow, 6).Value = Application.UserName
' .Protect Password:=""
' End With
errorhandler:
Application.EnableEvents = True
End Sub
leider kann ich das obere Erignis nicht mit dem ab Aenderung verknüpfen, deshalb auch der unter Bereich mit ' davor!
Ich möchte also unterschiedliche Ereignisse, je nachdem wo der Benutzer etwas eingibt!
Hat da jemand eine Lösung???
Danke im Voraus,
MfG
Benni