Results 1 to 8 of 8

Ways to expand search bar code? Thanks!!!

Threaded View

  1. #1
    Registered User
    Join Date
    07-09-2017
    Location
    United Kingdom
    MS-Off Ver
    2010
    Posts
    39

    Ways to expand search bar code? Thanks!!!

    Hi all,

    I have made a search bar on a userform that will be used for finding data values across the workbook from different worksheets.

    So far the search bar can only find values from "Sheet3". I want to modify the code so it can pick up data values from all worksheets in the workbook,

    The search bar pickup values regarding to range and displays each row of data within 15 different TxtBoxes.

    Below is the code I have used and a screenshot of my user form.


    Private Sub btnSearch_Click()
    Dim ws As Worksheet
    Dim strSearch As String
    Dim aCell As Range, v
    
    On Error GoTo Err
    
    'validate text box
    v = Trim(TextBox6.Value)
    If Len(v) = 0 Then
        MsgBox "Please Enter Data Value."
        Cancel = True
        Me.TextBox6.SetFocus
        Exit Sub
    End If
    
    Set aCell = Sheets("sheet3").Range("A:A").Find(v, lookat:=xlWhole)
    
    If Not aCell Is Nothing Then
    
        With aCell.EntireRow
    
            TextBox1.Text = .Cells(, "A").Value
            TextBox2.Text = .Cells(, "B").Value
            TextBox3.Text = .Cells(, "C").Value
            TextBox4.Text = .Cells(, "D").Value
            TextBox5.Text = .Cells(, "E").Value
            TextBox7.Text = .Cells(, "F").Value
            TextBox8.Text = .Cells(, "G").Value
            TextBox9.Text = .Cells(, "H").Value
            TextBox10.Text = .Cells(, "I").Value
            TextBox11.Text = .Cells(, "J").Value
            TextBox12.Text = .Cells(, "K").Value
            TextBox13.Text = .Cells(, "L").Value
            TextBox14.Text = .Cells(, "M").Value
            TextBox15.Text = .Cells(, "N").Value
     
           
    
        End With
    
    Else
        MsgBox "Data Value Not Found."
        Cancel = True
        'frmSearchTest.TextBox6.Value = ""
        TextBox6.SetFocus
    End If
    
    Exit Sub
    
    Err:
        MsgBox Err.Description
    
    End Sub
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Expand 'Search' to 2 columns
    By JO505 in forum Excel General
    Replies: 5
    Last Post: 11-23-2015, 05:08 AM
  2. Replies: 1
    Last Post: 05-24-2013, 06:02 AM
  3. [SOLVED] Ways to make my code run faster
    By JazzyBear in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2013, 03:59 PM
  4. [SOLVED] fastest ways to make a search
    By yberf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 11:08 AM
  5. WithEvents - same code run 2 ways: one causes crash
    By Deskmanbb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2011, 03:40 PM
  6. What are the good ways to write VBA code,
    By malviya_anil77 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-24-2011, 03:03 PM
  7. Two ways to search
    By 1000xx in forum Excel General
    Replies: 0
    Last Post: 05-21-2011, 04:48 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1