VLookup / HLookup Wildcard Search ?????

  • Thread starter Thread starter Shaka215
  • Start date Start date
S

Shaka215

Hi! I am trying to get the Vlookup code to do a search for search part
descriptions. I can get the normal Vlookup / Hlookup to work correctly
(only if the word is typed exactly) but I need this to be able to do a
search using wildcard characters...Please explain the logic behind the
code so that I can understand how to implement this into my
spreadsheet. I have looked at a few codes simlar to this request but
the logic behind the code isn't explained and I can't figure out how to
get information to be populated through those codes...Thanks alot!
 
Vlookup is a formula. What do you mean by code.

=Vlookup("ABC*",Sheet2!A:F,4,False)

in VBA code

Dim res as Variant
res = Application.Vlookup("ABC*",worksheets("Sheet2").Range("A:B"),4,False)
if iserror(res) then
msgbox "Not found"
else
msgbox "Results are " & res
End Sub

Wildcard characters a * for 0 to n characters and ? for a single character.
Experiment with your data to see what works. You know what you have and what
you want. If your part numbers are actually numbers and not text strings,
then wildcards are not going to work. You can possibly sort your data and
use the approximate match as described in the Excel help on Vlookup.

I would expect Hlookup to be consistent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top