Formula to make list shorter

Yaseraliakram

New Member
Joined
Nov 14, 2019
Messages
14
Hi guys,

I was wondering if somebody could help me with the following.
I have three columns, if somebody dials 93xxxxxxxx numbers the rate wil be charged 0.1575, and if someone dials 9320xxxxx the rate will also be charged0.1575.
In this case i want to delete the row with the prefix 9320. how ever the rate of 9325 is different so that i dont want to delete.
The same goes for 937500 should be deleten beceause if that prefix is not in the list the rate of the prefix 937 will be charged.

Can i do this witha formula ? See the excel list below.

Afghanistan930.1575
Afghanistan Kabul93200.1575
Afghanistan Kabul93250.16
Afghanistan Mobile9370.11172
Afghanistan Mobile AT93750.15382
Afghanistan Mobile AT9375000.15382
Afghanistan Mobile AWCC93700.13472
Afghanistan Mobile AWCC93710.13472
Afghanistan Mobile AWCC937110.13472
Afghanistan Mobile Etisalat93780.11172
Afghanistan Mobile MTN93760.11413
Afghanistan Mobile MTN93770.11413
Afghanistan Mobile Roshan93720.10238
Afghanistan Mobile Roshan93790.10238
Afghanistan Mobile Salam93740.13692

<colgroup><col style="mso-width-source:userset;mso-width-alt:9113;width:200pt" width="267"> <col style="mso-width-source:userset;mso-width-alt:3003;width:66pt" width="88"> <col style="mso-width-source:userset;mso-width-alt:2252;width:50pt" width="66"> </colgroup><tbody>
</tbody>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Assuming the data is stored in colums A through C, place this formula in row 2 of column D.

=IFERROR(VLOOKUP((NUMBERVALUE(LEFT($B2,5)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP((NUMBERVALUE(LEFT($B2,4)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP((NUMBERVALUE(LEFT($B2,3)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP((NUMBERVALUE(LEFT($B2,2)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP((NUMBERVALUE(LEFT($B2,1)),$B$1:$C1,2,FALSE)=C2,)))))

Assumptions made, there are no prefix codes longer then 6 digits.
The list is sorted as per your example (short to long and low to high)

The output will be either TRUE or FALSE. The TRUEs can be deleted.


The same goes for 937500 should be deleten beceause if that prefix is not in the list the rate of the prefix 9375 will be charged.
Fixed that for you. ;)
 
Upvote 0
hi

thanks for the reply

i think there is a problem with your formula, maybe not coppied good can you send again ?

=iferror(vlookup((numbervalue(left($b2,5)),$b$1:$c1,2,false)=c2,iferror(vlookup((numbervalue(left($b2,4)),$b$1:$c1,2,false)=c2,iferror(vlookup((numbervalue(left($b2,3)),$b$1:$c1,2,false)=c2,iferror(vlookup((numbervalue(left($b2,2)),$b$1:$c1,2,false)=c2,iferror(vlookup((numbervalue(left($b2,1)),$b$1:$c1,2,false)=c2,)))))
 
Upvote 0
there is still a problem with your formula mate...
the formula is not accepting, i am missing something
From my first reply, you have to paste all five rows in the same cell.

Does your version of excel use comma to break up formulas, or something else?
On this board typically commas are used, for instance LEFT($B2,5), but there are also versions of Excel that use semicolons LEFT($B2;5). Otherwise you might need to adjust the commas.
 
Upvote 0
@petertenthije
You have too many brackets in your formula, there is an extra bracket here
vlookup((numbervalue
for each lookup
 
Upvote 0
@petertenthije
You have too many brackets in your formula, there is an extra bracket here
vlookup((numbervalue
for each lookup
Thanks! That probably happened when I translated the formula from Dutch VERT.ZOEKEN to English VLOOKUP.

Type all five rows into cell D2, and copy down.

=IFERROR(VLOOKUP(NUMBERVALUE(LEFT($B2,5)),$B$1:$C1,2,FALSE)=C2,

IFERROR(VLOOKUP(NUMBERVALUE(LEFT($B2,4)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP(NUMBERVALUE(LEFT($B2,3)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP(NUMBERVALUE(LEFT($B2,2)),$B$1:$C1,2,FALSE)=C2,
IFERROR(VLOOKUP(NUMBERVALUE(LEFT($B2,1)),$B$1:$C1,2,FALSE)=C2,)))))
 
Upvote 0
yes, found the problem, it took me a while but i managed,
just a quick question further.

What if there are prefixes up to 12 digits ?
Can i use the same formula ?
 
Upvote 0
yes, found the problem, it took me a while but i managed,
just a quick question further.

What if there are prefixes up to 12 digits ?
Can i use the same formula ?
Sure, just add a copy of the first row, and modify the (LEFT($B2,5)) bit by increasing the 5 by the number of digits you want to review.
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,101
Members
449,205
Latest member
ralemanygarcia

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