+ Reply to Thread
Results 1 to 12 of 12

Struggling to use Vlookup and Left formula with telephone numbers

  1. #1
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Struggling to use Vlookup and Left formula with telephone numbers

    Hello guys,

    I have a list of UK mobile phone numbers which all start with 07. I have another list of UK mobile operator codes (e.g 07495 numbers are the mobile operator EE).

    I used a Left formula (=Left(a1), 5) to extract the first 5 numbers of my list of numbers and then did a Vlookup to assign the carrier name to each operators dial code in a separate column. However, I got quite a few "N/A"s. I then noticed that some of the carriers have 6 number dial codes (e.g. 074482 )

    Is there a way of saying if this mobile numbers starts with the either the 5 or 6 numbers in my list, then it is X operator please?

    Thanks for any advice offered.

  2. #2
    Forum Contributor
    Join Date
    03-17-2005
    Location
    Canterbury, Kent
    MS-Off Ver
    2003, 2010
    Posts
    285

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    Can you upload a sample of your data?

    If it has a six figure code does this give a 12 digit mobile number?

    Windy

  3. #3
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    Thanks Windy.

    prefix mobile network
    07107 O2
    07400 Three
    07401 Three
    07402 Three
    07403 Three
    07404 Lycamobile
    07405 Lycamobile
    074060 Cheers International
    074061 Cheers International
    074062 Cheers International
    074063 Vortex Telecom
    074064 Titanium
    074065 Telecom2
    074066 24 Seven Communications
    074067 TG Support
    074068 08Direct
    074069 CardBoardFish
    07407 Vodafone
    07408 Truphone
    07409 Orange
    07410 Orange
    07411 Three
    07412 Three
    07413 Three
    07414 Three
    07415 EE / T-Mobile
    07416 Orange
    074170 Three
    074171 CardBoardFish
    074172 UPA Telecom
    074173 Lycamobile
    074174 Lycamobile

    As you can see, some are 5 numbers, some are six. As you can see from the sample below, the first 5 numbers aren't necessarily assigned to 1 operator, its the 6th number that defines who the operator is in some cases.

    074061 Cheers International
    074062 Cheers International
    074063 Vortex Telecom
    074064 Titanium

    All mobile numbers are 11 numbers long, regardless of the length of the operator code p

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    You can get a list of all the codes for 07 phone numbers from the BT Pricing website, here:

    http://www.bt.com/pricing/current/Ca....htm#1631-d0e5

    and you can get a table of what the Type codes stand for here:

    http://www.bt.com/pricing/current/Ca....htm#0016-d0e5

    When I did this several years ago I sorted the lookup table by length of the phone number, so all the 4-digit codes were together, then the 5-digit codes etc., and used a formula that progressively looked at the first 4, then first 5 digits (up to 10), and took the match with the largest number of digits. It will take me some time to dig out the files, if you are interested.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    Hi Pete,

    Thanks for that. I also have a full list of mobile operators prefixes and carrier names from OFCOM's website (the government regulator).

    I'm not sure on your last part. All UK mobile numbers are 11 digits long. Also, all the phone numbers I have aren't in a split format, they are just 07123456789. If I do a vlookup after extracting the first 5 digits, it misses those carriers that are 6 digits. The list I have is huge and there are hundreds of smaller operators so it would take a very long time doing them manually. Also, as this will become a daily task, it'd be great if a formula could be found to speed things up.

    What I think I need, and not sure if possible, a formula that says if this number starts with this number then its XX operator.
    Last edited by ExcelsBiggestFan; 03-19-2016 at 07:55 AM.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    I developed a telephone analysis system which took any phone number and categorised it into the appropriate call type, i.e. Local, National, Mobile, International, International-mobile, Freephone, Directory Enquiries etc., and a Type_2 column gave further details for Mobile (operator) and International (country), so it was more sophisticated than just analysing Mobile calls and the number of digits in the phone number could vary from 3 digits (eg 999) up to 15 for some countries.

    Pete

  7. #7
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    If you think this could help, I'd be most grateful if you could find it. I'm quite good with my formulas and hoped there was an easy way to do this. Please, if you can't find it easily, please don't spend too long.

    I was thinking of using an IF statement with a left 5 statement with an IFERROR at the beginning but can't fully get my head around it
    Last edited by ExcelsBiggestFan; 03-19-2016 at 08:05 AM.

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,735

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    I've stripped out all the other stuff in the attached file, and set it up for 07 numbers only. In the Calls sheet I have put some mobile numbers in column A, and you can use this formula in B2:

    =INDEX(Types,MATCH(LEFT(A2,MAX(IF(ISERROR(MATCH(LEFT(A2,4),L_4,0)),0,4),IF(ISERROR(MATCH(LEFT(A2,5),L_5,0)),0,5),IF(ISERROR(MATCH(LEFT(A2,6),L_6,0)),0,6),IF(ISERROR(MATCH(LEFT(A2,7),L_7,0)),0,7))),Num,0))

    which can be copied down for as much data as you have in column A. The Destinations sheet contains the lookup table(s), with the part number in column A and the Operator or Type in column B. Note that I have sorted this data by length of code, and by the code itself, and that I have set up named ranges L_4 to L_7 to cover each length.

    In the red part of the formula, the first 4 digits are matched with the named range L_4 and returns 0 or 4, then in the blue part the first 5 digits are matched with the range L_5 and returns 0 or 5, and similarly with the green part (6) and the un-coloured part (7), and the formula then takes the largest of these and uses that number of digits in another LEFT function which then matches on the full range of numbers (Num), and returns the type. So, the formula will always take the largest number of digits to match on that it can, which enables you to take a range of numbers and reduce the entries needed in the lookup table.

    Note that the data in the table is quite old, based on a download from March 2009, so you will need to use more recent data (and to keep it up-to-date).

    Hope this helps.

    Pete
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    a little shorter...
    B2 =LOOKUP(2,1/SEARCH(Num,A2),Types)

  10. #10
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    HI Pete,

    Thanks so much for this, genuinely. I will look to adapt it today/tomorrow and come back with any questions if that's okay?

    Phuocam, thanks for responding. I'm not sure what this shortens, Pete's long formula above? I've not seen 1/SEARCH in a formula before. Could you explain a little about what it does. It would help my Excel knowledge development.


    Thanks both.
    Last edited by ExcelsBiggestFan; 03-19-2016 at 11:17 AM.

  11. #11
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    Sorry, corrected formula is: =LOOKUP(2,1/COUNTIF(A2,Num&"*"),Types)

  12. #12
    Registered User
    Join Date
    03-19-2016
    Location
    England
    MS-Off Ver
    2010 and 2013
    Posts
    17

    Re: Struggling to use Vlookup and Left formula with telephone numbers

    Okay, Pete, yours and Phuocams ideas both worked fine, thank you both. I can use this for another project also. For this one however, I chose to set up some VB code to auto
    1) add a Left(5) and Left(6) formula in new columns to extract the first 5 and 6 digits
    2) then did a vlookup of those 2 columns against my operator list
    3) then in a 3rd column said "If this is N/a" Then "That" Else "this".

    I created it in a macro so it works well, but perhaps a little around the block!

    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Do a vlookup based on left 6 numbers in the table
    By kafarrell in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 07-30-2014, 01:57 PM
  2. [SOLVED] Vlookup check - struggling with formula
    By JEB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2014, 07:31 AM
  3. Greetings and Formula to amend telephone numbers imported from Excel
    By stevebarham1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-09-2013, 11:39 AM
  4. Replies: 9
    Last Post: 02-04-2011, 06:14 AM
  5. telephone numbers
    By bella18 in forum Excel General
    Replies: 1
    Last Post: 04-19-2010, 11:09 AM
  6. Formatting telephone numbers?
    By MnO in forum Excel General
    Replies: 2
    Last Post: 01-17-2007, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1