+ Reply to Thread
Results 1 to 6 of 6

Display search result in message box

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Töreboda, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    11

    Display search result in message box

    Hi

    I want to search for a string in a entire workbook and if the string is found I want to display the entire row in a message box.
    The search string can occure in different columns and multiple times, if so, I want to display all rows in the message box.

    I hope someone can help me with this.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Display search result in message box

    maybe something like this?
    **Edit**
    i thought that at first you wanted to list the contents of each cell, so maybe this code isn't going to work for you see next posts for other solutions
    **Edit**

    Please Login or Register  to view this content.
    Last edited by scott.s.fower; 06-25-2013 at 08:54 PM. Reason: misread original post

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Display search result in message box

    if you want to display the addresses then use this one

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Display search result in message box

    or just the rows then use this one:
    how ever it will give you duplicate rows if it occurs more than once in a row

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Display search result in message box

    figured out how to avoid duplicate rows:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-27-2012
    Location
    Töreboda, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Display search result in message box

    Hi Scott,

    Thank you for your help. I'm new at this and can't get it to work, it don't seem to search in all cells and columns.

    I've this code that works, but I want to display the result in a message box rather than create a new sheet.
    I've tried for a while now but don't seem to be able to display the entire row in the message box.

    Here is the code I'm using, (this code is copied from Another thread).

    Sub FindAllSheets()
    Dim Found As Range, ws As Worksheet, LookFor As Variant
    LookFor = InputBox("Enter value to find")

    If LookFor = "" Then Exit Sub

    ' Clear or Add a Results sheet
    If SheetExists("Search Results") Then
    Sheets("Search Results").Activate
    Range("A2").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    Selection.ClearContents
    Else
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Name = "Search Results"
    End If

    For Each ws In ActiveWorkbook.Worksheets
    If ws.Name <> "Search Results" Then
    Set Found = ws.Cells.Find(What:=LookFor)
    If Found Is Nothing Then
    Range("D5").Select
    Else
    Found.EntireRow.Copy Sheets("Search results").Cells(Rows.Count, "A").End(xlUp).Offset(1)
    Result = Found.EntireRow
    End If
    End If
    Next ws
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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