+ Reply to Thread
Results 1 to 12 of 12

Evaluate one cell against an array

Hybrid View

tatoon Evaluate one cell against an... 10-29-2009, 06:49 AM
martindwilson Re: Evaluate one cell against... 10-29-2009, 08:16 AM
DonkeyOte Re: Evaluate one cell against... 10-29-2009, 08:18 AM
DonkeyOte Re: Evaluate one cell against... 10-29-2009, 08:20 AM
Palmetto Re: Evaluate one cell against... 10-29-2009, 08:19 AM
martindwilson Re: Evaluate one cell against... 10-29-2009, 08:30 AM
DonkeyOte Re: Evaluate one cell against... 10-29-2009, 08:35 AM
martindwilson Re: Evaluate one cell against... 10-29-2009, 08:55 AM
DonkeyOte Re: Evaluate one cell against... 10-29-2009, 09:01 AM
martindwilson Re: Evaluate one cell against... 10-29-2009, 09:08 AM
tatoon Re: Evaluate one cell against... 10-29-2009, 01:51 PM
tatoon Re: Evaluate one cell against... 10-29-2009, 05:38 PM
  1. #1
    Registered User
    Join Date
    10-29-2009
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2016
    Posts
    15

    Evaluate one cell against an array

    I have two sets of information, on one hand I have telephone numbers and in the other set I have prefixes and countries. My goal is to tell to which country each number belongs:

    i.e.


    Numbers Prefix Country
    4476324125 44 UK
    3354326544 33 France
    9713425432 971 UAE
    9143253245 91 India
    1343543253 1 USA
    4432412412
    4924241214
    7431242424



    So I would need to add a column next to "Numbers" saying to which country each number belongs.

    My list has a few thousand numbers and a couple of hundred prefixes.
    I tried with some array formula, but cannot make it work. Any idea on how this can be done? It would be interesting not to use VB.

    Thanx!
    Last edited by tatoon; 10-29-2009 at 07:00 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Evaluate one cell against an array

    try this i used a few helper columns then a lookup to avoid long nested if's
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Evaluate one cell against an array

    Unless your prefixes are all mutually exclusive (unlikely) you will need to add some additional logic to your criteria...

    To explain - USA is not the only dialling code beginning with 1 - eg Puerto Rico 1787 ... now although this may be a bad example I'm merely trying to illustrate how you will need to use logic in addition to the dialling code before you can try to assign numbers to codes.

    You could for ex. use length of number as an additional identifier.
    So adjacent to USA you may enter 10, ie USA numbers should be 10 digits in length inclusive of dialling code. Puerto Rico number length is likely to be different - ie 4 (code) + number

    Obviously if the number is 6 digits then you still have a problem, and some countries may have numbers of differing lengths (pending regional code etc...) so there are still obvious problems even utilising the above but this process will still to some extent lessen the risk of categorising numbers in error.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Evaluate one cell against an array

    Martin, FWIW, you could mirror your results without helpers using something like

    B1:
    =INDEX($I$1:$I$238,MATCH(TRUE,INDEX(($H$1:$H$238=LEFT($A1,LEN($H$1:$H$238))),0),0))

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Evaluate one cell against an array

    Edit: removed suggested formula and workbook. The solution is not viable based on details in subsequent posts
    Last edited by Palmetto; 10-29-2009 at 09:18 AM.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Evaluate one cell against an array

    yep thats a bit better(well quite alot really) donkeyote
    so heres v2 i moved duplicates to same row as well
    hm puerto rico i have as just 787 when dialed from europe not 1787 its only 1787 when called from usa/canada!
    Attached Files Attached Files
    Last edited by martindwilson; 10-29-2009 at 08:34 AM.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Evaluate one cell against an array

    Puerto Rico international code aside the general problems persists even with UK based codes ... eg:

    345* - Caymans or Spanish ?
    441* - Bermudan or UK ?

    etc I'm not sure with the info. provided a solution is viable.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Evaluate one cell against an array

    ok try version 3!
    Attached Files Attached Files

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Evaluate one cell against an array

    We will have to agree to disagree Martin... I don't think given the info we have this is a viable task.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Evaluate one cell against an array

    correction i see what you mean
    manchester is say +44161
    so digit string length and or 4th digit must come into play somehow
    now ive hade a better look bermuda from switzerland is +1441 not +441 so it depends now whether the numbers given show the full country code froma given location. then a lookup table should be able to pick them out
    Last edited by martindwilson; 10-29-2009 at 09:50 AM.

  11. #11
    Registered User
    Join Date
    10-29-2009
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: Evaluate one cell against an array

    Great!!

    It works, actually I took the version 2, everything in one column/formula.

    To avoid the problem you mention afterwards, I sort the prefixes in a descending order, so the first prefix that the formula will find will be the most exclusive.

  12. #12
    Registered User
    Join Date
    10-29-2009
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: Evaluate one cell against an array

    Actually adding a LARGE in the v2 formula gets the same results as in v3, but all in just one formula, but it makes the calculations too heavy for the CPU, it's not practical with my computer. Much faster sorting the numbers and using the v2 formula.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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