+ Reply to Thread
Results 1 to 6 of 6

test if there exists an "X" within a range of cells?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    test if there exists an "X" within a range of cells?

    Hello folks,

    how can we use an "If" statement to test if there exists an "X" character in any of the cells within a range?

    Thanks

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,508

    Re: test if there exists an "X" within a range of cells?

    is the "X" going to be the only character in the cell or is it just one letter among many like in A2 is X vs in A2 is 60X11A?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

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

    Re: test if there exists an "X" within a range of cells?

    Use the COUNTIF function:

    =COUNTIF(range,"X")>0
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,268

    Re: test if there exists an "X" within a range of cells?

    Maybe this:

    =IF(COUNTIF(A1:D9,"x")>0,"Present","Absent")

    Adjust the ranges to suit...
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  5. #5
    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,807

    Re: test if there exists an "X" within a range of cells?

    you can use
    =SUMPRODUCT(ISNUMBER(SEARCH("X",A4:A20))+0)>0
    which will return TRUE or FALSE

    then if true - use the IF

    =IF(SUMPRODUCT(ISNUMBER(SEARCH("X",A4:A20))+0)>0, "Range Contains an X" , "No X")
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  6. #6
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: test if there exists an "X" within a range of cells?

    Hello folks,

    Thanks for replying

    I did it like this, is this ok?

    Sub AutoFilterColA()
    Dim rngFoundCell As Range
          
    Set rngFoundCell = Sheets("Sheet1").Range("A6:A10").Find(What:="X")
           
    If rngFoundCell Is Nothing Then
        Range("A6") = "X"
    End If
    
    ...
    
    End Sub
    Thanks for your help

+ 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. Replies: 5
    Last Post: 01-23-2014, 11:02 AM
  2. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  3. [SOLVED] Pasting values between ranges in different workbooks: "Range" works but "Cells" doesn't
    By Flaubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2013, 01:19 PM
  4. Check if date exists in Named Range "Holiday_List"
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2012, 02:33 PM
  5. Problem using "Cells" in "Range" "400" error
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2009, 05:46 PM
  6. Test for "if selection includes cells outside range"
    By phenomenix in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2008, 04:47 PM
  7. Replies: 1
    Last Post: 01-30-2006, 06:10 PM
  8. What is the difference between 'Sheets("test")' and 'WorkSheets("test")' ???
    By Hutas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2005, 07:21 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