Closed Thread
Results 1 to 12 of 12

IF Function - Begins With

Hybrid View

  1. #1
    Registered User
    Join Date
    11-23-2005
    Posts
    61

    IF Function - Begins With

    How do I apply the "begins with" filter to an IF statement? I would like to test a match on the first 3 characters of a string in a given cell?

  2. #2
    Valued Forum Contributor
    Join Date
    03-25-2004
    Location
    Boston, MA US
    Posts
    1,094
    Cecil,

    =IF(LEFT(A1,3)="ABCD",A1,"")

    This will look at the 3 leftmost characters and return a value if it is true.

    Regards,

    Steve

  3. #3
    Valued Forum Contributor
    Join Date
    03-25-2004
    Location
    Boston, MA US
    Posts
    1,094
    Cecil,


    =IF(LEFT(A1,3)="ABC",A1,"")

    Only indicate 3 characters in quotes. My last example had 4. Sorry!

    Cheers,

    Steve

  4. #4
    Registered User
    Join Date
    11-23-2005
    Posts
    61
    Yes, that's it! Thanks, Steve.

  5. #5
    Registered User
    Join Date
    12-01-2016
    Location
    New York, NY
    MS-Off Ver
    Office 365
    Posts
    2

    Question Re: IF Function - Begins With

    Would this formula work on numbers, or do I need to change the numbers to text first?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: IF Function - Begins With

    Welcome to the board.

    What happened when you tried?
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    12-01-2016
    Location
    New York, NY
    MS-Off Ver
    Office 365
    Posts
    2

    Re: IF Function - Begins With

    Thanks! Long time lurker/learner from these forums, first time responding!

    I got an answer, but it wasn't the right one. It didn't error out.
    I think I'm going to try to do something along the line of the below since it is a number (once my brain can wrap around where this AND function goes along with the AND and ORs I already have going on...)

    =IF(AND(C1>=A1,C1<=B1),"between","not between")

    (from: http://www.mrexcel.com/forum/excel-q...wo-values.html)

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: IF Function - Begins With

    Good job sorting it out.

  9. #9
    Registered User
    Join Date
    03-16-2021
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    4

    Angry Re: IF Function - Begins With

    so I need to do something like if a3 starts with a then j3 has this output, or if a3 starts with x then j3has this output, I'm getting lost in the nesting

  10. #10
    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
    53,048

    Re: IF Function - Begins With

    Quote Originally Posted by mintyfresh2020 View Post
    so I need to do something like if a3 starts with a then j3 has this output, or if a3 starts with x then j3has this output, I'm getting lost in the nesting
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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

  11. #11
    Registered User
    Join Date
    06-04-2021
    Location
    Phoenix, AZ.
    MS-Off Ver
    Microsoft 365
    Posts
    5

    Re: IF Function - Begins With

    I am in need of an IF Function that will check the first three characters in Column B and Set a Text Value in Column A for that row

    Example: If Cell B1 = P42ABC123N, Then cell A1 is set to "F32"

    IF B1 Begins with P21, Set A1 to F21 or,
    If B1 Begins with P24, Set A1 to F24 or,
    If B1 Begins with P28, Set A1 to F28 or,
    If B1 Begins with P12, Set A1 to F32 or,
    If B1 Begins with P32, Set A1 to F32 or,
    If B1 Begins with P42, Set A1 to F32 or,
    If B1 Begins with P33, Set A1 to S33 or,
    If B1 Begins with P46, Set A1 to S46

  12. #12
    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. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,586

    Re: IF Function - Begins With

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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.

Closed 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