+ Reply to Thread
Results 1 to 7 of 7

Multiple IF statements and LEFT function in one cell

Hybrid View

roadwreck Multiple IF statements and... 12-15-2021, 09:58 AM
AliGW Re: Multiple IF statements... 12-15-2021, 10:00 AM
AliGW Re: Multiple IF statements... 12-15-2021, 10:03 AM
JohnTopley Re: Multiple IF statements... 12-15-2021, 10:09 AM
roadwreck Re: Multiple IF statements... 12-15-2021, 10:19 AM
queuesef Re: Multiple IF statements... 12-15-2021, 10:19 AM
AliGW Re: Multiple IF statements... 12-15-2021, 10:46 AM
  1. #1
    Registered User
    Join Date
    07-12-2016
    Location
    Estonia
    MS-Off Ver
    2016
    Posts
    12

    Multiple IF statements and LEFT function in one cell

    Hello

    In column C i have ID numbers. The first digit refers to gender and in column D needs values based on that. If it is male than "M" and if female than "F".

    3 and 5 - male
    4 and 6 - female

    I have tried using different IF nesting functions but haven't found one that works. For example =IF(LEFT(C3;1)=3;5;"M";IF(LEFT(C3;1)=4;6;"N")), but this says that too many arguments for this function.

    Hopefully someone can lead me to the right path with this
    Attached Files Attached Files
    Last edited by AliGW; 12-15-2021 at 10:01 AM. Reason: Restricted word redacted.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,387

    Re: Multiple IF statements and LEFT function in one cell

    Administrative Note:

    Members will tailor the solutions they offer to the version of Office (Excel) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,387

    Re: Multiple IF statements and LEFT function in one cell

    A bit less clumsy perhaps:

    =LOOKUP(--LEFT(C3,1),{3,4,5,6},{"M","F","M","F"})

    Otherwise you will need two OR statements.

    You may need to replace commas with semi-colons for your locale (which is why your location is important to us).
    Attached Files Attached Files
    Last edited by AliGW; 12-15-2021 at 10:06 AM.

  4. #4
    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,736

    Re: Multiple IF statements and LEFT function in one cell

    Try

    =IF(OR(LEFT(C3,1)="3",LEFT(C3,1)="5"),"M",IF(OR(LEFT(C3,1)="4",LEFT(C3,1)="6"),"F","N"))

    change "," to ";"

    Please update LOCATION in your profile
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    07-12-2016
    Location
    Estonia
    MS-Off Ver
    2016
    Posts
    12

    Re: Multiple IF statements and LEFT function in one cell

    Thank you AliGW and JohnTopley!

    Both solutions work as needed.

    Many thanks again

  6. #6
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Multiple IF statements and LEFT function in one cell

    copy to cell F3, then copy down.
    =IF(OR(VALUE(LEFT(C3,1))=3,VALUE(LEFT(C3,1))=5),"M",IF(OR(VALUE(LEFT(C3,1))=4,VALUE(LEFT(C3,1))=6),"F","neither"))
    I like Ali's (Does it (ali's) work if it is none of the numbers? )
    Last edited by queuesef; 12-15-2021 at 10:22 AM.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,387

    Re: Multiple IF statements and LEFT function in one cell

    I like Ali's (Does it (ali's) work if it is none of the numbers? )

    Perhaps:

    =IFERROR(LOOKUP(--LEFT(C3,1),{3,4,5,6},{"M","F","M","F"}),"Non-Gender")

    Thank you AliGW and JohnTopley!
    Thanks for the rep.

+ 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 Match variable combine with Left function
    By rogrand in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-22-2021, 04:58 PM
  2. [SOLVED] If/or/not multiple with left function
    By Questray in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 05-05-2020, 12:07 PM
  3. [SOLVED] running a function with multiple variables left blank
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2016, 04:03 PM
  4. Writing function with multiple (13) if/and/then statements
    By JOHNROK in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-03-2012, 10:03 AM
  5. [SOLVED] If And Or Left function in multiple cells
    By sans in forum Excel General
    Replies: 13
    Last Post: 04-24-2012, 04:30 AM
  6. Excel 2007 : Left Function with possible IF statements?
    By jantonio in forum Excel General
    Replies: 3
    Last Post: 01-08-2010, 08:29 PM
  7. Logical Function - Multiple IF statements
    By vnsrod2000 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-04-2005, 08:06 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