i have
column A > list of numbers(codes)
column B > list of name(of products) assigned with code in column A

i generate a code from different choice what i select in another provision in excel(same sheet)

now required(generated) code to be find is like 12300456000. here all zero are variables(0 shows that any value at that place is acceptable).. means i want to find ALL codes from column A having 123XX456XXX, here XX and XXX are variables. also its position can be changed. i.e. another required code may be 1XX23456XXX.

i want the list of the all product having codes similar to required i.e. like 123XX456XXX.

[ i used VLOOKUP but it gives only one result n0t all and it can not search for variables].

thank you in advance..

I answered this. Not sure why it's still here. You need a user-defined VBA function. If cell F1 contains the pattern and A1:A100 contains the range of test numbers, you can enter this in a cell:
and fill down.
Here's the function:

Public Function GetLike(Rg As Range, Pattern As String, whichOne As Integer)
Dim Check As String, n As Integer
   Check = Application.Substitute(Pattern, "0", "?")
   GetLike = ""
   For Each thing In Rg
       If thing Like Check Then
         n = n + 1
         If n = whichOne Then
         GetLike = thing
         Exit Function
         End If
       End If
End Function

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Bob Umlas


I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at http://www.thumbtack.com/ny/new-york/excel-training/


Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Excellence, The Expert, Microsoft

BA in math, Hofstra University, 1965

Awards and Honors
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2017 About.com. All rights reserved.