Probleme mit Find
23.07.2003 14:01:26
Regina
ich docktere schon ein paar Tage an dem Problem rum, komm jetzt nicht weiter
Es soll der Betrag in Tab1 spalte 5 in der Tab 2 Spalte 11 gesucht werden,
weil es mehrere identische Beträge gibt, soll bei Übereinstimmung der Beträge geprüft werden, ob die VSN (eine Lange Nummer) aus TAb 2 Spalte 4, in der Tab 1 Spalte 3 vorhanden ist (in Spalte 3 stehen aber noch andere Zahlen und Buchstaben).
erst wenn das auch der Fall ist, soll in Tab2 Spalte 12 der Wert aus Tab1 Spalte 3 eingetragen werden. Ich hoffe ich konnte mich verständlich machen.
Hier mein Code:
Sub RLSlisteVergleichMitKto()
Dim i As Long
Dim c As Long
Dim VSN As Range
Dim Tb1 As Worksheet
Dim Tb2 As Worksheet
Dim such
Set Tb1 = Worksheets("RLS") 'Tabellennamen eintragen
Set Tb2 = Worksheets("RLS180703") ' Tabellenname eintragen
Application.ScreenUpdating = False
For i = 3 To Tb2.Cells(Rows.Count, 1).End(xlUp).Row
Application.StatusBar = " Bearbeite Zeile" & i & "von" & Tb2.Cells(Rows.Count, 1).End(xlUp).Row
For c = 2 To Tb1.Cells(Rows.Count, 1).End(xlUp).Row
If IsEmpty(Tb2.Cells(c, 12)) Then
' damit nur noch offene zugeordnet werden
If Tb1.Cells(i, 5) = Tb2.Cells(c, 11) Then
With Tb1.Cells(Rows.Count, 1).End(xlUp).Row
VSN = Tb2.Cells(c, 4)
Set such = Tb1.Cells(i, 3).Find(what:=VSN, lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not such Is Nothing Then
Tb2.Cells(c, 12) = Tb1.Cells(i, 3)
Tb1.Cells(i, 6) = Tb2.Cells(c, 4)
Tb1.Cells(i, 7) = Tb2.Cells(c, 1)
End If
End With
End If
End If
Next
Next
Application.ScreenUpdating = True
Application.StatusBar = False
MsgBox "Fertig"
End Sub
bis ich die Find Abfrage eingefügt habe lief es,aber hat nicht richtig zugeordnet.
Vielleicht kann mir jemand helfen.
schonmal Vielen Dank im voraus.
Gruß Regina
Anzeige