+ Reply to Thread
Results 1 to 4 of 4

IF statement based on presence or absence of a specific character.

  1. #1
    Forum Contributor
    Join Date
    02-09-2011
    Location
    Perth, Australia
    MS-Off Ver
    2016
    Posts
    161

    IF statement based on presence or absence of a specific character.

    Hi Forum,

    I want to set up an IF statement that determines if a specific character (“_”) is present in a part number and then returns a result accordingly.

    Is there a function that can be used in an IF statement that works like “Contains’ when you do a filter?

    It would work like:

    =IF(A2 Contains “_”, “Yes”, “No”)

    Is there a way to set up an IF statement to work like this?

    Thanks very much

    Dave

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: IF statement based on presence or absence of a specific character.

    Hi, Dave,

    InStr will return the position of the first character of the search string in the original string (so if gretaer 0 there´s a match), and Like will compare the strings
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: IF statement based on presence or absence of a specific character.

    Try
    =IF(ISNUMBER(FIND("_", A2)), "underscore present", "not")
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

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

    Re: IF statement based on presence or absence of a specific character.

    Also note that in your sample you are using “_” while excel would be expecting "_" “” vs ""
    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

+ 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. Macro/VBA to Add Rows based on presence/absence of specific text content
    By cmaunder in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2013, 01:15 PM
  2. [SOLVED] Macro/VBA to Change Order of Rows/Add Rows based on specific text content presence/absence
    By cmaunder in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2013, 04:50 PM
  3. Decision based on presence/absence of picture
    By terry.joyce in forum Excel General
    Replies: 3
    Last Post: 08-01-2010, 06:26 PM
  4. Presence/absence chart
    By asrit7 in forum Excel General
    Replies: 2
    Last Post: 10-07-2007, 04:39 PM
  5. Search for a specific character in a cell in an if statement
    By mcl in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-04-2005, 06: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