Clever-Excel-Forum

Normale Version: in einer Formel ?
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo kann man das in einer formel schreiben? A6 bis A17  und  C6 bis C17 ???????? statt es 17 x zuschreiben



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Target.Address = "$C$6" Or Target.Address = "$D$6" Then
        Range("C6").Value = Range("C6").Value + Range("D6").Value
    End If
    Application.EnableEvents = True

    Application.EnableEvents = False
    If Target.Address = "$C$7" Or Target.Address = "$D$7" Then
        Range("C7").Value = Range("C7").Value + Range("D7").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$8" Or Target.Address = "$D$8" Then
        Range("C8").Value = Range("C8").Value + Range("D8").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$9" Or Target.Address = "$D$9" Then
        Range("C9").Value = Range("C9").Value + Range("D9").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$10" Or Target.Address = "$D$10" Then
        Range("C10").Value = Range("C10").Value + Range("D10").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$11" Or Target.Address = "$D$11" Then
        Range("C11").Value = Range("C11").Value + Range("D11").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$12" Or Target.Address = "$D$12" Then
        Range("C12").Value = Range("C12").Value + Range("D12").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$13" Or Target.Address = "$D$13" Then
        Range("C13").Value = Range("C13").Value + Range("D13").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$14" Or Target.Address = "$D$14" Then
        Range("C14").Value = Range("C14").Value + Range("D14").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$15" Or Target.Address = "$D$15" Then
        Range("C15").Value = Range("C15").Value + Range("D15").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$16" Or Target.Address = "$D$16" Then
        Range("C16").Value = Range("C16").Value + Range("D16").Value
    End If
    Application.EnableEvents = True
   
    Application.EnableEvents = False
    If Target.Address = "$C$17" Or Target.Address = "$D$17" Then
        Range("C17").Value = Range("C17").Value + Range("D17").Value
    End If
    Application.EnableEvents = True
End Sub
Hallo so,
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("C6").Resize(17, 2)) Is Nothing Then
  Application.EnableEvents = False
  Cells(Target.Row, 3) = Cells(Target.Row, 3) + Cells(Target.Row, 4)
  Application.EnableEvents = True
End If
End Sub
Danke