+ Reply to Thread
Results 1 to 12 of 12

Excel 2007 : Formula needed to check if cell data DOESN'T match data in list

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Question Formula needed to check if cell data DOESN'T match data in list

    I'm trying to sort out a formatting formula, based on the following:

    =COUNTIF($A$1:$A$20,B1)

    I have a list of fixed data (A1-A20, formatted as text, but some values contain numbers and letters - eg. 12F20, 429NG, 1ED48)

    I need to add data in colB. If the data I enter in column B does not match any of the data in colA, I want it to format (turn red, go bold, whatever)

    The formula I used above checks if the data matches, and formats it instead. I've tried

    =COUNTIF($A$1:$A$20,"<>B1")

    but that doesn't work either, it still formats the cell if it matches.

    I'm sure it's so simple, but I just can't see it!!

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Formula needed to check if cell data DOESN'T match data in list

    Either:

    =COUNTIF($A$1:$A$20,$B1)=0
    or

    =ISNA(MATCH($B1,$A$1:$A$20,0))
    Above assumes case insensitive tests ... if you need exact / case sensitive matches (eg Apple <> apple) let us know

  3. #3
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    Hi - thanks for a fast response!!

    Both codes do work, sort of...

    say in ColB I've added 10 different letter/number data. The last one to go in (so line 10), shows as not matching, despite it clearly showing in my ColA list.

    But when I add another cell of data underneath it in line 11, line 10 suddenly shows it matches, and the new line 11 now shows as not matching, again, despite it being in the ColA list.

    This is the case for both codes - as though it looks at the cell below to see if it matches, and puts the format on the cell above. Any suggestions?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Formula needed to check if cell data DOESN'T match data in list

    Clear whatever rules you have in place and start again.

    Select the range from B1 down (important) and apply the rule as outlined.

  5. #5
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    Cleared off completely, re-entered as advised....

    Still the bottom cell of data is always showing as a non-match until something is entered underneath it, and now also not matching certain info at all, despited being in the list, in the same format, same cases etc etc.

    Have even tried it on a brand new worksheet,pasting in the same info (values only), and still does the same.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Formula needed to check if cell data DOESN'T match data in list

    Hi Dancing,

    I have the same problem.
    But when I use it in code it works just fine.


    Sub ColourCells()
        Dim LastRow As Long
        LastRow = Range("A65536").End(xlUp).Row
        Range("A1").Select
        With Range("A1:A" & LastRow).FormatConditions
            .Delete
            .Add Type:=xlExpression, Formula1:="=isna(MATCH(A1,$B$1,0))"
            .Item(1).Interior.ColorIndex = 6
        End With
    
    End Sub

  7. #7
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    Could it be cos I'm entering it in the actual formatting formula box (Cond formatting -> New Rule -> Use a formula to determine...), rather than any programming box (which I have zero xp of btw...)?

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Formula needed to check if cell data DOESN'T match data in list

    Post a sample file illustrating the problem.

    I would add that you should also add an IF to the rule to negate blanks assuming these should be ignored but we can deal with once we have a sample.

  9. #9
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    Not sure what I did/was doing, but a couple of times of clearing it and re-doing and it's now working as needed Can't really post a sample file without chopping most of it out due to sensitive info in the rest of the sheet.

    Where abouts would the 'IF' go to make it ignore any blanks? I'm using the "=countif" formula, as the other one was still causing problems)

    Thanks for your patience and help btw.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Formula needed to check if cell data DOESN'T match data in list

    Add a pre-emptive IF along the lines of:

    =IF($B1<>"",COUNTIF($A$1:$A$20,$B1))

  11. #11
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    super - many many many thanks

  12. #12
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Formula needed to check if cell data DOESN'T match data in list

    super - many many many thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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