Vlookup multiple numbers from string

MHamid

Active Member
Joined
Jan 31, 2013
Messages
472
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I am not certain if this is possible or not, but would there be a way to perform a vlookup for multiple numbers (one at a time) against another sheet?
For instance, 06500- |All LVIDs|blah blah blah ...|blah blah blah;11111- |All LVIDs|blah blah blah ...|blah blah blah;11000- |All LVIDs|blah blah blah ...|blah blah blah
The numbers I need to search for in another file are always 5 digits long and are always before the dash(-).
The formula I am looking for will need to look at the cell with the text ("A1") and if one of these 5 digit numbers (06500, 11111, 11000) is in another sheet, then say "Yes". If not, then say "No".
Not all data will have multiple IDs like my example above.

Is this possible with a formula or would be it better with a macro?

Thank you
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try the following UDF

VBA Code:
Function LookupNumber(sText As String)
  Dim c As Variant, x As String, f As Range
  LookupNumber = "No"
  For Each c In Split(sText, "-")
    x = Right(c, 5)
    If Len(x) = 5 And IsNumeric(x) Then
      Set f = Sheets("Sheet1").Range("A:A").Find(x, , xlValues, xlWhole)
      If Not f Is Nothing Then LookupNumber = "Yes"
    End If
  Next
End Function

The UDF searches each number on sheet1 in column A

HOW TO INSTALL UDFs
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use LookupNumber just like it was a built-in Excel function. For example:

Dante Amor
AB
10600- |All LVIDs|blah blah blah ...|blah blah blah;11111- |All LVIDs|blah blah blah ...|blah blah blah;11000- |All Yes
2
Sheet3
Cell Formulas
RangeFormula
B1B1=LookupNumber(A1)
 
Upvote 0
Hello,

The sheet that I need the formula for is a Shared EUC spreadsheet. Are there any restrictions when using UDFs or can anyone still use/see results for the UDF if they open the spreadsheet?

Thank you
 
Upvote 0
Did you try the udf with sheets from your book?

Is that what you need?
What do you mean with :
The sheet that I need the formula for is a Shared EUC spreadsheet. Are there any restrictions when using UDFs or can anyone still use/see results for the UDF if they open the spreadsheet?
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top