Results 1 to 5 of 5

Search Multiple columns for string, display matching results on different sheet.

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-21-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    258

    Search Multiple columns for string, display matching results on different sheet.

    Hey Guys,

    Ripped this code from another site, it runs fine with no errors but never finds any results.
    Tried tweaking it a couple of different ways to no avail. Anyone have any ideas how to get this to work? I just want to search columns A to E and display the matching Rows (columns A to F) on the sheet 'Search Results'

    Sub Search()
        'Standard Sheet Module code, like: Sheet1.
        Dim iFound
        Dim Message$, Title$, Default$, myCode$
        Dim cell1, cell2, rng As Range
        Set cell1 = Cells(2, 1)
        Set cell2 = cell1.End(xlDown).End(xlToRight)
        Set rng = Range(cell1, cell2)
        Message = "Enter Search Data:" ' Set prompt.
        Title = "Search" ' Set title.
        Default = "" ' Set default.
        ' Display message, title, and default value.
        myCode = InputBox(Message, Title, Default)
    
        iFound = False
        Application.ScreenUpdating = False
    
        'Check data sheet for data wanted!
        Worksheets("Box Index").Select
        For Each r In Worksheets("Box Index").UsedRange.Columns
        n = r.Column
    
        If Worksheets("Box Index").Cells(n, 1) = myCode Then
        iFound = True
        'Copy the found data from the starting row = myStart to
        'the ending row = myFinish for the Found Date [myDate]
        'to Sheet2 in column "C" change as needed!
        'Start data import just below any entery in this column!
        Worksheets("Box Index").Range(Cells(1, n), Cells(5, n)).Copy _
        Destination:=Worksheets("Search Results").Range("C65536").End(xlUp).Offset(1, 0)
        Else
    
        End If
        Next r
    
        If iFound = False Then MsgBox "No Results Found"
        Application.CutCopyMode = True
        Application.ScreenUpdating = True
        End Sub
    Last edited by RichTea88; 08-06-2013 at 06:08 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Search for a partial string match and cycle through matching results
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2013, 08:27 AM
  2. Display multiple search results in a row
    By Alicita in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 01-24-2011, 10:45 AM
  3. VBA Search Column for matching string in another sheet
    By photopidge in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-16-2010, 01:09 PM
  4. Search sheet and display results
    By Tony Vargo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2008, 06:58 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