Restricting an INDEX MATCH to a specific number of characters RIGHT from the last character

dougmarkham

Active Member
Joined
Jul 19, 2016
Messages
252
Office Version
  1. 365
Platform
  1. Windows
Hi Folks,

I have a simple problem: my INDEX MATCH formula matches 'the first 3 characters RIGHT from the last character' of postcode data in one column; matching it with, any 'postcode data' in another column---this formula returns zone information.

I have the following named ranges:

  • Table 1, Col A = PostCodes
  • Table 2, Col A = FedExPostcodes
  • Table 2, Col C = FedExZones
Here is the formula I've tried and got working...
Code:
=INDEX([COLOR=#008000][B]FedExZones[/B][/COLOR],MATCH(RIGHT([B][COLOR=#b22222]PostCodes[/COLOR][/B],[B]3[/B])&"*",[COLOR=#0000ff][B]FedExPostCodes[/B][/COLOR],[B]0[/B]))

I need to modify this formula so it INDEX MATCHES 'the first 3 characters RIGHT from the last character' of postcode data in one column with 'the first 3 characters RIGHT from the last character' of postcode data in another column---this would then return only zone information for exact postcode matches

Here is the same formula I've tried to modify to achieve a like for like match---this formula returns the error message #VALUE .
Code:
=INDEX([COLOR=#008000][B]FedExZones[/B][/COLOR],MATCH(RIGHT([B][COLOR=#b22222]PostCodes[/COLOR][/B],3)&"*",RIGHT([COLOR=#0000ff][B]FedExPostCodes[/B][/COLOR],3),0))

I've outlined the situation below
Any help would be greatly appreciated!

Kind regards,

Doug.




Situation: I have two worksheets -
  • FIRST: address data including postcodes (UK zip codes),
  • SECOND: listed FedEx postcodes and FedEx zone information.

Aim: I wish to do an INDEX MATCH (in Table 1, Col C) to compare postcodes from table 1 and table 2, and return the correct FedEx zone.


  • WkSht 1 = Address book [contains Table 1]
  • WkSht 2 = FedEx Postcodes/Zones [contains Table 2]

WkSht 1; Table 1: My Address book
Col A (Postcodes)Col B (Character Length [=Len(A2:A5)])Col C (lookup of FedExZone)
FK1 (A2)3DB (C2)
FK23DB
FK33#N/A
FK53#N/A

<tbody>
</tbody>







WkSht 2; Table 2: FedEx Postcode/Zone table
Col A (FedEx Postcodes)Col B (Postcode Character Length [=Len(A2:A4)]Col C (FedEx zone)
FK19 (A2)4DB
FK204DB
FK214DB

<tbody>
</tbody>

I have managed to do this with the following formula:
Code:
=INDEX([COLOR=#008000][B]FedExZones[/B][/COLOR],MATCH(RIGHT([B][COLOR=#b22222]PostCodes[/COLOR][/B],[B]3[/B])&"*",[COLOR=#0000ff][B]FedExPostCodes[/B][/COLOR],[B]0[/B]))
What I think my formula stipulates is:
  • exactly match the RIGHT 3 characters of the values in the named range PostCodes with the named range FedExPostCodes and return data from the named range FedExZones.
In this situation, the zone information in Table 1 cell C2 is returning zone DB when I need it to return a non-match i.e., #N/A.

The issue:

The formula works except when...
  • the Table 2 postcodes have 4 characters (eg., FK19 [cell A2]) and...
  • the Table 1 postcodes have 3 matching characters e.g., FK1 [cell A2] within the 4 characters (eg., FK19 [cell A2]) .
How would I modify this formula to say the following???
  • exactly match the RIGHT 3 characters of the values in the named range PostCodes with the RIGYHT 3 characters of the values in the named range FedExPostCodes and return data from the named range FedExZones

I tried this and it returned #VALUE error messages.
Code:
=INDEX([COLOR=#008000][B]FedExZones[/B][/COLOR],MATCH(RIGHT([B][COLOR=#b22222]PostCodes[/COLOR][/B],3)&"*",RIGHT([COLOR=#0000ff][B]FedExPostCodes[/B][/COLOR],3),0))
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
16 people have read this so far and you haven't got one reply.
I think you've overcomplicated the problem by pasting a very lengthy description, that's the sort of thing that puts people off.

Put simply,
What's your input and what output are you trying to get, example data please.

Why isn't this just a simple INDEX(...MATCH(...)) ?
 
Upvote 0
=INDEX(FedExZones,MATCH(RIGHT(PostCodes,3)&"*",RIGHT(FedExPostCodes,3),0))
Try the same formula as ARRAY formula.
How to enter ARRAY formula.

To enter ARRAY formula
Paste the formula
Press F2
Press Ctrl+Shift+Enter keys together.
formula will be covered with{} brackets by excel.
=INDEX(FedExZones,MATCH(RIGHT(PostCodes,3)&"*",RIGHT(FedExPostCodes,3),0))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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