ich habe ein Problem mit dem Auslesen von Daten mit bestimmten Kriterium.
Wenn in Tabelle "Data" 2 x die Projektnummer steht wird nur der letzte Datensatz ausgelesen.
Danke!
Gruß, Olga
https://www.herber.de/bbs/user/110304.xlsm
Private Sub CommandButton5_Click()
Dim lSp As Long, lSp1 As Long, lSp2 As Long, Anz As Long, Z As Long, lRe As Long, AufAnz As _
Long, X As Long
Dim ii As Long, loEnde1 As Long
Dim lw As Integer, ly As Integer
Dim iRowL As Integer
Stop
ListBox1.Clear
With Sheets("Auslesen")
ii = .Cells(.Rows.Count, 4).End(xlUp).Row
If ii > 1 Then .Range(.Cells(2, 1), .Cells(ii, 6)).ClearContents
End With
lw = 2
With Sheets("Data")
lSp = .Rows(1).Find(what:="Proj_Nr", lookat:=xlWhole, LookIn:=xlValues).Column
lSp1 = .Rows(1).Find(what:="ANG_ANZAHL", lookat:=xlWhole, LookIn:=xlValues).Column
loEnde1 = 2
lSp2 = lSp1 + 1
For ii = lw To .Cells(Rows.Count, 1).End(xlUp).Row
If .Cells(ii, lSp) = UF.txtProjNr.Value Then
Sheets("Auslesen").Cells(loEnde1, 1).Resize(1, 6).Value = _
.Cells(ii, lSp2).Resize(1, 6).Value
loEnde1 = loEnde1 + 1
End If
Next ii
End With
With Sheets("Auslesen")
iRowL = .Cells(Rows.Count, 1).End(xlUp).Row
UF.ListBox1.List = Range(.Cells(2, 1), .Cells(iRowL, 6)).Value
End With
End Sub
Schöne Grüße,