Partial cell Match

chadlaw32

Board Regular
Joined
Jul 29, 2014
Messages
84
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I am trying to right a formula that will look up the firs set of values in a cell where there are numbers separated by a dash below is an example of the data. I want to look up the 301 or 024. Any ideas?
[TABLE="width: 91"]
<colgroup><col></colgroup><tbody>[TR]
[TD]301-513410[/TD]
[/TR]
[TR]
[TD]303-545826[/TD]
[/TR]
[TR]
[TD]024-562515[/TD]
[/TR]
[TR]
[TD]303-556837[/TD]
[/TR]
[TR]
[TD]027-499338[/TD]
[/TR]
[TR]
[TD]303-557957[/TD]
[/TR]
[TR]
[TD]313-518514[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Here is a VBA solution to try

Code:
Option Explicit


Sub chadlaw()
    Dim lr As Long, i As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row    'change the range to the column you are testing
    For i = 2 To lr    'assumes you have a header in the column
        If InStr(Range("A" & i), "301-") Or InStr(Range("A" & i), "024-") Then
            MsgBox "Found"
            Exit Sub
        End If
    Next i
End Sub
Standard Module
How to install your new code
Copy the Excel VBA code
Select the workbook in which you want to store the Excel VBA code
Press Alt+F11 to open the Visual Basic Editor
Choose Insert > Module
Edit > Paste the macro into the module that appeared
Close the VBEditor
Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)


To run the Excel VBA code:
Press Alt-F8 to open the macro list
Select a macro in the list
Click the Run button
 
Upvote 0
What i want is a vlookup for the values before the dash the numbers in he cell are 678-456235 and i want to reference the 678
 
Upvote 0
What i want is a vlookup for the values before the dash the numbers in he cell are 678-456235 and i want to reference the 678

=VLOOKUP(X2&"*",Table,1,0)


where X2 = 678 and Table is the range housing those 7 values you forwarded in your initial post.
 
Upvote 0
The sheet has account numbers in column B2 and those are 678-456789 and 123-987654 where 678 or 123 reference a franchise i want to run a vlookup on B2 for a table that list all the franchise.
 
Upvote 0
The sheet has account numbers in column B2 and those are 678-456789 and 123-987654 where 678 or 123 reference a franchise i want to run a vlookup on B2 for a table that list all the franchise.

I don't understand what you mean by franchise... Is it not just this what you need?


Book1
BCDE
1
2301-513410678678-456789
3303-545826123123-987654
4024-562515
5303-556837
6027-499338
7303-557957
8313-518514
9678-456789
10123-987654
11
Sheet1


E2 copied down:

=VLOOKUP(D2&"*",B:B,1,0)
 
Upvote 0
Get rid of column D I want to look up part of column B. 301 an 303 and 024 on your table where i have another table that says 301 is city A and 303 is city b and 024 is city C.
 
Upvote 0
Try

=VLOOKUP(VALUE(LEFT(B2,3)),City_Names_Table,2,0)

where City_Names_Table is the 2(at least)-column table that you're referring to as "another table" in post # 8!

EDIT: because missed the 024

either
=VLOOKUP(VALUE(LEFT(B2,3)),City_Names_Table,2,0)
or
=IF(VALUE(LEFT(B4,3))<100,VLOOKUP(TEXT(LEFT(B4,3),"000"),City_Names_Table,2,0),VLOOKUP(VALUE(LEFT(B4,3)),City_Names_Table,2,0))
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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