VLook-Up Match first 3 characters of one cell with another column

Kulsumbi

New Member
Joined
Oct 4, 2020
Messages
8
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Serial #ResultTownidMyUniq
1235661231111
1234562762222
2764554563333
2764567894444
4567780005555

I want to match first 3 letters of "serial #" against "town ID's" if it matches then "myuniq id" must fill in the result cell.


Please assist
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
like this?
Serial #ResultTownidMyUniq
12356611111231111
1234562762222
2764554563333
2764567894444
4567780005555
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TypeText = Table.TransformColumnTypes(Source,{{"Serial #", type text}, {"Townid", type text}}),
    Result = Table.AddColumn(TypeText, "Result", each if Text.Start([#"Serial #"],3) = [Townid] then [MyUniq] else null),
    Reorder = Table.ReorderColumns(Result,{"Serial #", "Result", "Townid", "MyUniq"})
in
    Reorder
Serial #TownidMyUniqSerial #ResultTownidMyUniq
123566123111112356611111231111
12345627622221234562762222
27645545633332764554563333
27645678944442764567894444
45677800055554567780005555

or (with your example)
Excel Formula:
=IF(LEFT(A2,3)=C2,D2,"")
 
Last edited:
Upvote 0
or
Book1
LMNO
3Serial #ResultTownidMyUniq
412356611111231111
512345611112762222
627645522224563333
727645622227894444
845677833330005555
Sheet3
Cell Formulas
RangeFormula
M4:M8M4=INDEX($O$4:$O$8,MATCH(--LEFT(L4,3),$N$4:$N$8,0))
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    Text = Table.TransformColumnTypes(Source,{{"Serial #", type text}, {"Townid", type text}}),
    Three = Table.AddColumn(Text, "Custom", each Text.Start([#"Serial #"],3)),
    Join = Table.NestedJoin(Three,{"Townid"},Three,{"Custom"},"Table",JoinKind.Inner),
    Expand = Table.ExpandTableColumn(Join, "Table", {"MyUniq"}, {"MyUniq.1"}),
    RC = Table.RemoveColumns(Expand,{"Custom"}),
    Reorder = Table.ReorderColumns(RC,{"Serial #", "MyUniq", "Townid", "MyUniq.1"}),
    Ren = Table.RenameColumns(Reorder,{{"MyUniq", "Result"}, {"MyUniq.1", "MyUniq"}})
in
    Ren
Serial #ResultTownidMyUniq
12356611111231111
12356611111232222
12345622222763333
12345622222764444
27645533334565555
 
Upvote 0
Works
or
Book1
LMNO
3Serial #ResultTownidMyUniq
412356611111231111
512345611112762222
627645522224563333
727645622227894444
845677833330005555
Sheet3
Cell Formulas
RangeFormula
M4:M8M4=INDEX($O$4:$O$8,MATCH(--LEFT(L4,3),$N$4:$N$8,0))
Works fine for the above table..

However it's shows N/A for the below table where serial number starts with 002.

Serialresulttown idmy id
002123123N/A0039999
 
Upvote 0
Book1
LMNO
3Serial #ResultTownidMyUniq
412356611111231111
512345611112762222
627645522224563333
727645622227894444
845677833330025555
900267855555426666
Sheet3
Cell Formulas
RangeFormula
M4:M9M4=INDEX($O$4:$O$8,MATCH(LEFT(L4,3),BASE($N$4:$N$8,10,3),0))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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