How to show relative value in searched values?

Fractalis

Active Member
Joined
Oct 11, 2011
Messages
328
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I want to search within range A1:B16 the CODE for each NUM in D1 to D8 with one condition.

There are some CODEs that are of the form XXXXZZ and XXXX24 that belongs to the same "group". The CODE that ends with 2 numbers is the "MAIN" CODE within than group.

The "MAIN" CODES begins with 333391.

For example, XNUMTE and XNUM49 belongs to same group and main is XNUM49. Following this example, depending the numbers searched, the formula matches XNUMTE or XNUM49.

In E2:E8 the output is correct, but when in output there is a MAIN CODE, I'd like to show MAIN value instead the other CODE for that group like in output H2:H8.

How can I do this in Excel 2019?

I hope make sense. Thanks

file.xlsx
ABCDEFGH
1CODENUMNUMCODENUMCODE
2ACGUSG13123147965SBDRUD7965SBDRUD
3ACGUSG1404725120631DLTNLT120631DLTN75
4DLTNLT12063133339145DLTN7533339145DLTN75
5DLTN75333391451404725ACGUSG1404725ACGUSG
6DLTNLT3165405275497XNUMTE5275497XNUM49
7DLTNLT3460643233663XNUMTE233663XNUM49
8SBDRUD796533339100XNUM4933339100XNUM49
9SBDR12796660
10SBDRUD33339183
11SBDRUD7967
12XNUMTE5199799
13XNUMTE233663
14XNUM4933339100
15XNUMTE52551223
16XNUMTE5275497
Sheet12
Cell Formulas
RangeFormula
E2:E8E2=INDEX($A$1:$A$16,MATCH(D2&"*",$B$1:$B$16,0))
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Book3
ABCDE
1CODENUMNUMCODE
2ACGUSG13123147965SBDR12
3ACGUSG1404725120631DLTN75
4DLTNLT12063133339145DLTN75
5DLTN75333391451404725ACGUSG
6DLTNLT3165405275497XNUM49
7DLTNLT3460643233663XNUM49
8SBDRUD796533339100XNUM49
9SBDR12796660
10SBDRUD33339183
11SBDRUD7967
12XNUMTE5199799
13XNUMTE233663
14XNUM4933339100
15XNUMTE52551223
16XNUMTE5275497
Sheet1
Cell Formulas
RangeFormula
E2:E8E2=IFERROR(LOOKUP(2,1/(LEFT($A$2:$A$16,4)=LEFT(INDEX($A$2:$A$16,MATCH(D2,$B$2:$B$16,0)),4))/ISNUMBER(RIGHT($A$2:$A$16,2)+0),$A$2:$A$16),INDEX($A$2:$A$16,MATCH(D2,$B$2:$B$16,0)))
 
Upvote 0
Thanks for your answer. It almost work, but for some reason the first value shows SBDR12 instead of SBDRUD.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
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