Option Explicit Sub Einfuegen() Dim SpalteA() As Variant, SpalteAneu() As Variant Dim ArrIndex0 As Long, ArrIndex1 As Long, SpA1zeilen As Long, SpA2zeilen As Long Columns("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=True SpA1zeilen = Cells(Rows.Count, 1).End(xlUp).Row SpalteA() = Range("A1:L" & SpA1zeilen) Range("A1:L" & SpA1zeilen) = "" Columns("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=False SpA2zeilen = Cells(Rows.Count, 1).End(xlUp).Row SpalteAneu() = Range("A1:L" & SpA2zeilen) For ArrIndex0 = 1 To SpA2zeilen For ArrIndex1 = 1 To SpA1zeilen If SpalteA(ArrIndex1, 1) = SpalteAneu(ArrIndex0, 1) And SpalteA(ArrIndex1, 1) <> "" And SpalteAneu(ArrIndex0, 1) <> "" Then SpalteA(ArrIndex1, 12) = SpalteA(ArrIndex1, 12) + SpalteAneu(ArrIndex0, 12) End If Next ArrIndex1 Next ArrIndex0 Range("A1:L" & SpA1zeilen & SpA2zeilen) = "" Range("A1:L" & SpA1zeilen) = SpalteA() End Sub
Option Explicit Sub Einfuegen() Call EventsOff Dim SpalteA() As Variant, SpalteAneu() As Variant Dim ArrIndex0 As Long, ArrIndex1 As Long, SpA1zeilen As Long, SpA2zeilen As Long Columns("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=True SpA1zeilen = Cells(Rows.Count, 1).End(xlUp).Row SpalteA() = Range("A1:L" & SpA1zeilen) Range("A1:L" & SpA1zeilen) = "" Columns("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=False SpA2zeilen = Cells(Rows.Count, 1).End(xlUp).Row SpalteAneu() = Range("A1:L" & SpA2zeilen) For ArrIndex0 = 1 To SpA2zeilen For ArrIndex1 = 1 To SpA1zeilen If SpalteA(ArrIndex1, 1) = SpalteAneu(ArrIndex0, 1) And SpalteA(ArrIndex1, 1) <> "" And SpalteAneu(ArrIndex0, 1) <> "" Then SpalteA(ArrIndex1, 12) = SpalteA(ArrIndex1, 12) + SpalteAneu(ArrIndex0, 12) Exit For End If Next ArrIndex1 Next ArrIndex0 Range("A1:L" & SpA2zeilen) = "" Range("A1:L" & SpA1zeilen) = SpalteA() Call EventsOn End Sub
Public Sub EventsOff() With Application .ScreenUpdating = False .EnableEvents = False .Calculation = xlCalculationManual End With End Sub
Public Sub EventsOn() With Application .ScreenUpdating = True .EnableEvents = True .Calculation = xlCalculationAutomatic End With End Sub
58.7k Fragen
251k Antworten
7.3k Nutzer