ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VLookup / HLookup Wildcard Search ????? (https://www.excelbanter.com/excel-programming/362843-vlookup-hlookup-wildcard-search.html)

[email protected]

VLookup / HLookup Wildcard Search ?????
 
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!


Tom Ogilvy

VLookup / HLookup Wildcard Search ?????
 
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").Ra nge("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.

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy



" wrote:

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!




All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com