Hi Stephan,
hier eine Lösung des Problems in VBA:
Tabelle 1
Spalte A |
Spalte B |
Müller |
7 |
Möller |
9 |
Müller |
11 |
Müller |
4 |
Greb |
12 |
Möller |
11 |
Greb |
6 |
Tabelle 2
Dim Name, Wert
Sub Start()
Dim Bis
Bis = 0
Range("A1").End(xlDown).Select
Bis = ActiveCell.Row
For x = 2 To Bis
Name = Range("A" & x)
Wert = Range("B" & x)
Verarbeitung
Next x
End Sub
Sub Verarbeitung()
Dim Bis2
Bis2 = 0
Sheets("Tabelle2").Select
Range("A1").End(xlDown).Select
Bis2 = ActiveCell.Row
If Bis2 > 100 Then
Bis2 = 2
Range("A" & Bis2) = Name
Range("B" & Bis2) = Wert
Range("A2:B" & Bis2).Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1 _
:=xlSortNormal
Sheets("Tabelle1").Select
Exit Sub
End If
For y = 2 To Bis2 Step 1
If Range("A" & y) = Name Then
Range("B" & y) = Range("B" & y) + Wert
Sheets("Tabelle1").Select
Exit Sub
End If
Next y
Range("A" & Bis2).Select
If Bis2 > 1 Then _
Selection.Offset(1, 0).Range("A1").Select
Bis2 = ActiveCell.Row
Range("A" & Bis2) = Name
Range("B" & Bis2) = Range("B" & Bis2) + Wert
Range("A2:B" & Bis2).Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1 _
:=xlSortNormal
Sheets("Tabelle1").Select
End Sub
Hoffe, ich konnte helfen.
|