+ Reply to Thread
Results 1 to 15 of 15

Search box possibilities

Hybrid View

  1. #1
    Registered User
    Join Date
    01-25-2017
    Location
    Worcester
    MS-Off Ver
    2016
    Posts
    93

    Search box possibilities

    I am questioning if it's possible to create a search box on sheet1 for example, type in a reference number then when clicking Search it takes you to the sheet that contains that reference number?

    The reason for this is I am wanting to share some inventory data with our IT Service Desk and to allow them the ability to search and find the inventory stock at the click of the button is invaluable. I know the Find & Select feature already offers this but I'm looking for a sexier way of performing it.

    Any thoughts?

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    Yes there is ...
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-25-2017
    Location
    Worcester
    MS-Off Ver
    2016
    Posts
    93

    Re: Search box possibilities

    Thank god, I hoped there was.

    Any chance of that snippet of information on how to do it?

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim ws As Worksheet, rng As Range
        If Not Intersect(Target, Range("A1")) Is Nothing Then
            For Each ws In ThisWorkbook.Sheets
                If ws.Name <> ActiveSheet.Name Then
                    With ws.UsedRange
                        Set rng = .Find(Target, LookIn:=xlValues, lookat:=xlWhole)
                        If Not rng Is Nothing Then Application.Goto rng
                    End With
                End If
            Next ws
        End If
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-25-2017
    Location
    Worcester
    MS-Off Ver
    2016
    Posts
    93

    Re: Search box possibilities

    Ahhhhh you are clever Sintek brilliant. Can this be assigned to a text box so it can be created into a button or graphic? Something like this for example.
    Capture.JPG
    Last edited by smudgers9; 12-28-2017 at 11:09 AM.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    Here you go...
    Attached Files Attached Files

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    An absolute pleasure...That's how I also started off...Enjoy, tx for rep+

  8. #8
    Registered User
    Join Date
    01-25-2017
    Location
    Worcester
    MS-Off Ver
    2016
    Posts
    93

    Re: Search box possibilities

    Hi Sintek,

    Is it possible to generate an error message if the number entered in the search box doesn't exist? I can't seem to get it to work. Simply saying "This number does not exist"
    Also if nothing is entered in the search box can an error be generated to say "A search number is required" or something to this affect?
    Last edited by smudgers9; 01-02-2018 at 10:58 AM. Reason: more info

  9. #9
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Search box possibilities

    Add the changes into sinteks code
    Option Explicit
    
    Sub Picture2_Click()
    Dim ws As Worksheet, rng As Range, Fnd As String
    Fnd = Sheet1.TextBox1.Text
    If Sheet1.TextBox1.Text = "" Then
    MsgBox " Please enter a number"
    Exit Sub
    End If
    For Each ws In ThisWorkbook.Sheets
        If ws.Name <> ActiveSheet.Name Then
            With ws.UsedRange
                Set rng = .Find(Fnd, LookIn:=xlValues, lookat:=xlWhole)
                If Not rng Is Nothing Then
                    Application.Goto rng
                    Exit Sub
                    Else: MsgBox "Entered number does not exist"
                    Exit Sub
                End If
            End With
        End If
    Next ws
    End Sub

  10. #10
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Search box possibilities

    enter middle line of code into your code....will look at if doesnt exist

    Fnd = Sheet1.TextBox1.Text
    If Sheet1.TextBox1.Text = "" Then MsgBox " Please enter a number"
    For Each ws In ThisWorkbook.Sheets

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    @nigelog

    Close...This part will error on first worksheet loop if no value found
    Else: MsgBox "Entered number does not exist"

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search box possibilities

    Option Explicit
    
    Sub Picture2_Click()
    Dim ws As Worksheet, rng As Range, Fnd As String
    Fnd = Sheet1.TextBox1.Text
    If Fnd = "" Then
        MsgBox "A SEARCH NUMBER IS REQUIRED", vbInformation, ""
        Exit Sub
    End If
    For Each ws In ThisWorkbook.Sheets
        If ws.Name <> ActiveSheet.Name Then
            With ws.UsedRange
                Set rng = .Find(Fnd, LookIn:=xlValues, lookat:=xlWhole)
                If Not rng Is Nothing Then
                    Application.Goto rng
                    Exit Sub
                End If
            End With
        End If
    Next ws
    MsgBox "NUMBER DOES NOT EXIST", vbInformation, ""
    End Sub

  13. #13
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Search box possibilities

    @ sintek

    Much tidier solution

  14. #14
    Registered User
    Join Date
    01-25-2017
    Location
    Worcester
    MS-Off Ver
    2016
    Posts
    93

    Re: Search box possibilities

    Thank you both so much, this works a dream.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. All possibilities for two tables?
    By SILENTBRONCO in forum Excel General
    Replies: 4
    Last Post: 06-21-2016, 07:36 PM
  2. New to the Possibilities of Excel
    By Old4xford in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-09-2014, 01:11 AM
  3. Vlookup & Sum if possibilities
    By dcad81 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 06:00 PM
  4. Replies: 2
    Last Post: 04-11-2013, 08:27 PM
  5. An if statement for more than two possibilities
    By percivaltroy in forum Excel General
    Replies: 2
    Last Post: 05-25-2009, 04:29 AM
  6. [SOLVED] Excel/VBA possibilities
    By The Alltime Best in forum Excel General
    Replies: 2
    Last Post: 04-30-2006, 04:25 PM
  7. Thousands of possibilities
    By sharkfoot in forum Excel General
    Replies: 5
    Last Post: 03-27-2006, 12:15 AM

Tags for this Thread

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