Dann brauche ich eine Kombi aus diesen beiden Codes. Beide einzeln laufen natürlich nciht
wegen den Deklarationen und es kann nur ein Worksheet_Change geben! Die Datei soll aber alle Funktionen der beiden Codes
können!
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim R&, C&, rng As Range, sumCell As Range
With Target
R = .Row
C = .Column
Set sumCell = Cells(R, 11)
If R > 33 Or .Value = "" Then
sumCell = ""
Application.EnableEvents = True
Exit Sub
End If
Select Case C
Case Is > 8, Is < 4: Exit Sub
End Select
Set rng = Range(Cells(R, 4), Cells(R, 8))
rng.ClearContents
If .Value <> "x" Then .Value = "x"
sumCell = (8 - C) * Cells(R, 3) 'Summe
End With
Application.EnableEvents = True
End Sub
UND
OptionExplicit
PrivateSubWorksheet_Change(ByValTarget AsRange)
DimC&, NichtLeer AsBoolean, R&, Wert#, V
Application.EnableEvents = False
On Error GoTo ExitSub
With Target
R = .Row
C = .Column
V = .Value
End With
Select Case R
Case Is> 14, Is< 5
Application.EnableEvents = True
Exit Sub
End Select
Select Case C
Case Is> 7, Is< 4
Application.EnableEvents = True
Exit Sub
Case4: If V = "x" Then Wert = 3
Case Else: If V = "x" Then Wert = 1
End Select
If Wert <> 0 Then
Cells(11 + R, 3) = Wert
Else
If Cells(R, 8).End(xlToLeft).Column < 4 Then
Cells(11 + R, 3) = ""
End If
End If
Exit Sub:
Application.EnableEvents = True
End Sub
|
|