ich verzweifle grad an folgender Situation:
In einer Quelltabelle gibt es in Spalte K eine Institusbezeichnung.
Nun sollen entsprechend der Institute diese Datensätze in neue Tabellen kopiert werden.
D.h. alle aus dem InstitutA nach Tabelle InstitutA ,alle aus B nach B, u.s.w.
dazu hatte ich mir folgendes überlegt:
Code:
Option Explicit
Sub Institut_Select()
Dim ws1 As Worksheet, ws2 As Worksheet, n As Long, pos As Long
Set ws1 = Worksheets("Quelldaten")
Set ws2 = Worksheets("Institute1")
Set ws3 = Worksheets("Institute2")
pos = 1
With ws1
For n = 1 To .Cells(65536, 11).End(xlUp).Row
If .Cells(n, 11) Like "InstitutA" Then
.Cells(n, 11).EntireRow.Copy Destination:=ws2.Cells(pos, 1)
pos = pos + 1
End If
Next n
End With
With ws1
For n = 1 To .Cells(65536, 11).End(xlUp).Row
If .Cells(n, 11) Like "InstitutB" Then
.Cells(n, 11).EntireRow.Copy Destination:=ws3.Cells(pos, 1)
pos = pos + 1
End If
Next n
End With
End Sub
Problem:
Es werden irgendwelche Zeilen Kopiert, aber nicht die, in der die entsprechende Institutsbezeichnung steht.
Wo ist mein Denkfehler ?
Steffen