Text box 5 =Code:'find the Last row: TextBox5.Text = oWB.Sheets(1).Cells(oSheet.Rows.Count, 1).End(-4162).Row() 'Test search A1:C Value from Textbox1 Dim suchRng As Excel.Range = oSheet.Range("A1:" & "C" & TextBox5.Text) Dim Row, Col As Long For Each rng As Excel.Range In suchRng If String.IsNullOrEmpty(rng.Value) Then rng.Value = Nothing ListBox1.Items.Add(rng.Address & "Empty " & rng.Offset(Row, Col).Value) ElseIf rng.Value.ToString = Form1.textbox2.Text Then 'add the Cell and the Text to Listbox ListBox1.Items.Add(rng.Address & " " & rng.Offset(Row, Col).Value) End If Next
the last row containing text
list box =
the spreadsheet contains stock codes in column A and descriptions in B. I only want to search for matches in column B, but as you can see the list box only shows empty cells.




Reply With Quote
