+ Reply to Thread
Results 1 to 4 of 4

EMBEDDED IF/THEN function with multiple AND/OR conditions

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    Tel-Aviv
    MS-Off Ver
    Excel for Mac version 14.3.9
    Posts
    2

    EMBEDDED IF/THEN function with multiple AND/OR conditions

    Hello,

    I have a difficult scenario which I cannot wrap my head around, I hope there's an Excel PRO here who can help me!

    It has to do with editing and formatting telephone numbers and country codes.

    Here it is:


    EMBED:
    C2 = IF A2=France AND IF B2 has 9 digits AND IF B2 starts with 6, THEN add "33" to the beginning of B2, otherwise copy as is
    C2 = IF A2=Belgium AND IF B2 has 9 digits AND IF B2 starts with 47 OR 48 OR 49, THEN add "32" to the beginning of B2, otherwise copy as is
    C2 = IF A2=United Kingdom AND IF B2 has 10 digits AND IF B2 starts with 71 OR 73 OR 74 OR 75 OR 77 OR 78 OR 79, THEN add "44" to the beginning of B2, otherwise copy as is

    etc... there are a lot of countries with different conditions

    HOW DO I EMBED SO MANY CONDITIONS ???

    I would really really appreciate any help !

    Thanks to all

    Eli

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,948

    Re: EMBEDDED IF/THEN function with multiple AND/OR conditions

    Probably some sort of table(s) LOOKUP (Country, Length of number, "Starts with .." values ,Prefix(es) (44, 33 etc).

    Have you (or can you create) such a table? Or reasonable sample covering extremes?

  3. #3
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: EMBEDDED IF/THEN function with multiple AND/OR conditions

    =IF(AND(A3="FRANCE",LEN(B3)=9,VALUE(LEFT(B3,1))=6),"33"&B3,IF(AND(A3="BELGIUM",LEN(B3)=9,(OR(VALUE(LEFT(B3,2))=47,VALUE(LEFT(B3,2))=47,VALUE(LEFT(B3,2))=49))),"44"&B3,B3))

    the trick is to break it down.

    Where I have to build complex nested if statements I use a blank sheet and write each element in and build it up slowly

    easiest thing to do is remember that each different 1sst element (in this case country) would need its only IF statement to be places in the If False clause of the previous statement. (ie. if X = X, do this, else do this)
    then use a mixture of AND(case1, case2, case3) and OR(case1, case2, case3) to build up the rest.

  4. #4
    Registered User
    Join Date
    05-18-2016
    Location
    Tel-Aviv
    MS-Off Ver
    Excel for Mac version 14.3.9
    Posts
    2

    Re: EMBEDDED IF/THEN function with multiple AND/OR conditions

    Kramxel - Thank you, very very helpful. I figured out how to do it thanks to your advice.
    All the best!

+ 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. multiple conditions which function to use
    By bbis21 in forum Excel General
    Replies: 7
    Last Post: 11-20-2014, 09:42 PM
  2. [SOLVED] IF function help, multiple conditions
    By wantucce in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2014, 12:22 PM
  3. Sum if Conditions embedded in a INDEX MATCH function
    By DaNmAc26 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-28-2012, 01:30 PM
  4. Excel 2007 : If Function With Multiple Conditions
    By AaronNeutron in forum Excel General
    Replies: 2
    Last Post: 02-21-2012, 03:52 AM
  5. multiple conditions on an If function.
    By hedgefund in forum Excel General
    Replies: 1
    Last Post: 04-21-2010, 09:42 PM
  6. Looking for a function for multiple conditions
    By MrSales in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-16-2007, 03:27 PM
  7. If Function with Multiple Conditions
    By tlosgyl3 in forum Excel General
    Replies: 6
    Last Post: 07-10-2006, 08:29 PM

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