Results 1 to 21 of 21

Thread: Find Next in a Search

Threaded View

  1. #14

    Thread Starter
    Lively Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    123

    Re: Find Next in a Search

    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
    Text box 5 =
    the last row containing text



    list box =
    Name:  Capture1.PNG
Views: 1046
Size:  8.1 KB

    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.
    Attached Images Attached Images  
    Last edited by callumwk; Sep 12th, 2017 at 08:33 AM.
    VS 2017 - Need as much help as you can give (write it all for me!)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width