+ Reply to Thread
Results 1 to 2 of 2

Search with wild (*) character

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-01-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    112

    Search with wild (*) character

    Hello Excel Gurus,

    I have the code below that needs minor revision. Right now it only display the exact match when found.

    The revision I want is if I type “ENGLISH” on cell “A2”, it will display all the Description that contain the word “ENGLISH” whether it is “ENGLISH/SPANISH” or “ENGLISH VERSION”, “SPANISH/ENGLISH”, “English/Italian”, “Spanish-Eng”, etc. as long as the cell contain the word “ENGLISH" whether in the beginning, middle or last. (Lower or upper case). Maybe a search with wild (*) character.

    Also, if 2 or more exact match is found, display only one. (remove duplicate)

    I am newbie on writing a Macro.

    Any help would be appreciated.

    Thank you.

    HERE IS THE CODE
    Option Explicit
    Option Compare Text
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim Rng         As Range
    Dim Dn          As Range
    Dim Dic         As Object
    Dim Temp        As String
    Dim oCols       As String
    Dim R           As Range
    Dim C           As Long
    
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
    With Sheets("DATA1")
        Set Rng = .Range(.Range("Q1"), .Range("Q" & Rows.Count).End(xlUp))
    End With
    
    Set Dic = CreateObject("scripting.dictionary")
        Dic.CompareMode = vbTextCompare
    C = 5
    For Each Dn In Rng
        If Not Dic.exists(Dn.Value) Then
            Dic.Add Dn.Value, Dn
        Else
            Set Dic.Item(Dn.Value) = Union(Dic.Item(Dn.Value), Dn)
        End If
    Next
    
    C = 5
        With Sheets("DTR")
            .Unprotect Password:="."
            .Range(.Range("A6"), .Range("A" & Rows.Count).End(xlUp)).Resize(, 3).ClearContents
            .Range("A5").Resize(, 3).Value = Array("DESCRIPTION", "SKU NO.", "LOCATION")
                
            If Dic.exists(.Range("A2").Value) Then
                For Each R In Dic.Item(.Range("A2").Value)
                    C = C + 1
                    .Range("A" & C).Resize(, 3).Value = R.Offset(, -14).Resize(, 3).Value
                Next R
            End If
        
            .Protect Password:=".", DrawingObjects:=True, Contents:=True, Scenarios:=True
    End With
    
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    End Sub

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,838

    Re: Search with wild (*) character

    Cross-posted at: http://www.mrexcel.com/forum/excel-q...character.html
    For cross-posting etiquette, please read FORUM RULE 8: http://www.excelforum.com/forum-rule...rum-rules.html
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ 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. [SOLVED] Wild character sumproduct...
    By Amolvijay in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-17-2014, 07:36 AM
  2. Wild Card Character search using Excel VBA
    By s.anurag1786 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2013, 11:18 PM
  3. what wild character to use for choosing numbers
    By purplewarda in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2008, 12:40 AM
  4. Possible? Trying to do a wild card search...
    By andyd2k in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-05-2006, 01:13 PM
  5. [SOLVED] Activating / Closing workbook using part name and a wild character
    By sharman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-24-2005, 11:05 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