0

I have a problem, so i try to toop trough a range and insert everv found item into a listbox. So far so good, the first row was found, but then nothing?

Dim ItemRange As Range: Set ItemRange = Data.Range("Data!A1:F300") ''Set the range within I want to look for
Dim HelpRange As Range: Set HelpRange = ItemRange 
Dim Found As Range: Set Found = ItemRange.Find(TextBox_Search.Value)

Do Until Found Is Nothing
    i = Found.Row
    If k = i Then
        Exit Do
    End If

    k = i

    ListBox_Item.AddItem
    ListBox_Item.List(j, 0) = i

    j = j + 1

    Set HelpRange = Range(Cells(i, 1), Cells(300, 6))  ''Set the range new, so the value isnt fount twice

    Set Found = Nothing
    Set Found = HelpRange.Find(TextBox_Search.Value)


Loop

There is some other Data to find, but i didnt understand why it is not found??

Philip
  • 3
  • 2
  • 2
    `ItemRange` is pointing at the Sheet "Data". But when you rebuild `HelpRange`, you don't specify any sheet, so it is pointing at `ActiveSheet`. This may be creating a range in the wrong sheet, which would cause the `Find` to fail. Try `Set HelpRange = Data.Cells(i, 1).Resize(301 - i, 6)` – Toddleson Mar 17 '22 at 15:13
  • 1
    @Toddleson thanks a lot, that solves my problem – Philip Mar 17 '22 at 15:43

0 Answers0