+ Reply to Thread
Results 1 to 6 of 6

Macro for searching a spreasheet for text/value/.

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2013
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Macro for searching a spreasheet for text/value/.

    All,

    I'm putting to together a spreadsheet for material requisition for a construction project. These spreadsheets tend to grow very large. Sometimes I need to search for a specific item using a purchase number or description. The filters offer some help but it would be awesome if i could designate one cell where i could input a purchase number or text that searches the spreadsheet and highlights all the hits. Say, Cell N2 is to be my "search cell." can someone help this I would greatly appreciate it.

    emondragon 07

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro for searching a spreasheet for text/value/.

    Please attach a sample. It is doable

  3. #3
    Registered User
    Join Date
    01-10-2013
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Macro for searching a spreasheet for text/value/.

    Yes please see attached document and thank you!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro for searching a spreasheet for text/value/.

    Emo,
    I see you have attached a sample. I also see you have data in sheet "SHEET METAL". Now, you want to search for a PO. Where? Is it in this sheet only. You have a PO in column G, Or do you wish to search across multisheets?

  5. #5
    Registered User
    Join Date
    01-10-2013
    Location
    CA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Macro for searching a spreasheet for text/value/.

    AB33,

    I would like to search for a PO or if someone wanted to, even search for words within the item description column if possible. I would like it to search just within the active sheet. So in this case just SHEET METAL. So essentially I would like the search to be flexible in what I choose to type. Lots of times there will be the same PO number for different material so in this case typing a search by item description would be better even just key words. If you can do both that would be awesome. If i need to provide more information I will. Thank you for the response.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro for searching a spreasheet for text/value/.

    Here is one way. The code highlightes the entire row. You can easily change the findme

    For e,g you can set it like

    findme= "Your stirng to search" . In this code, the findme is linked to a cell reference

    Sub serachme()
      
    Dim rFind As Range, Findme As String, sAddr As String, ws As Worksheet
    
    Set ws = Sheets("SHEET METAL")
    
    Findme = ws.Range("G6")
    
    
            With ws.UsedRange
                Set rFind = .Find(What:=Findme, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
                If Not rFind Is Nothing Then
                    sAddr = rFind.Address
                    Do
                        rFind.EntireRow.Interior.Color = vbRed
                        
                        Set rFind = .FindNext(rFind)
                    Loop While rFind.Address <> sAddr
                    sAddr = ""
                End If
            End With
    
    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