+ Reply to Thread
Results 1 to 8 of 8

Help with MID function, multiple if's

  1. #1
    Registered User
    Join Date
    03-23-2013
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    36

    Help with MID function, multiple if's

    Please help.

    I got following formula:

    IF(MID(A238,5,4)="TEST", IF(A237="CTAG",A236,J237)," ")

    This works for me, but in first call, i would like to next more ifs, for example:

    IF(MID(A238,5,4)="TEST",
    IF(MID(A238,5,5)="TEST1",
    IF(MID(A238,5,3)="TES,
    IF(MID(A238,5,7)="TEST123",

    and end with, IF(A237="CTAG",A236,J237)," ")

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: Help with MID function, multiple if's

    IF(MID(A238,5,4)="TEST",
    IF(MID(A238,5,5)="TEST1",
    IF(MID(A238,5,3)="TES,
    IF(MID(A238,5,7)="TEST123",

    so all those above if true

    then use an OR

    IF(OR(MID(A238,5,4)="TEST", MID(A238,5,5)="TEST1", MID(A238,5,3)="TES", MID(A238,5,7)="TEST123") , IF(A237="CTAG",A236,J237)," ")

    Or do the first 3 characters always = TES ?

  3. #3
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Help with MID function, multiple if's

    In your original formula where you have " " replace with a new if:

    =IF(MID(A238,5,4)="TEST", IF(A237="CTAG",A236,J237),IF(MID(A238,5,5)="TEST1",A,B))

    Where A is what you want to do if that is true and B is when false. Again replace B with another IF statement.

    Or if you want the same output for each test you can try:

    =IF(OR(MID(A238,5,4)="TEST",IF(MID(A238,5,5)="TEST1",IF(MID(A238,5,3)="TES,IF(MID(A238,5,7)="TEST123"),IF(A237="CTAG",A236,J237)," ")

    As long as one of your checks is true then it will move onto the A237 bit.
    Say thanks, click *

  4. #4
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Help with MID function, multiple if's

    As etaf has pointed out if you go down the OR route because you want the same output from your formula for each check you may aswell just check for TES which wil cover all your given situations

  5. #5
    Registered User
    Join Date
    03-23-2013
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Help with MID function, multiple if's

    Thanks, but, my checks do not have same names. Will try OR function. Thanks!

  6. #6
    Registered User
    Join Date
    03-23-2013
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Help with MID function, multiple if's

    I cannot get that OR formula to work, error states that formula has error... any ideas?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Help with MID function, multiple if's

    Try this. You can skip the test for "Tes", they all begin with that. Then, start with the shortest, and work towards the longest - that way it will work through the word progressively...

    IF(OR(MID(A238,5,4)="TEST",MID(A238,5,5)="TEST1",MID(A238,5,7)="TEST123"),IF(A237="CTAG",A236,J237)," ")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: Help with MID function, multiple if's

    I cannot get that OR formula to work, error states that formula has error... any ideas?
    works ok for me
    Attached Files Attached Files

+ 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