+ Reply to Thread
Results 1 to 13 of 13

COUNTIF Formula

  1. #1
    Registered User
    Join Date
    11-15-2007
    Posts
    9

    COUNTIF Formula

    Hello,
    I am trying to use the COUNTIF formula to compare between text column of 2different sheets; sheet1 & sheet 2 (A column in each).
    When it finds a cell that is identical to both columns, it marks an "X" next to that cell.
    Ideas anyone?
    Thanks much!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    try something like,

    in Sheet1, B2,

    =If(Countif(Sheet2!A:A,A2),"X","") copied down

    where Sheet2!A:A is the column to compare against A2 on the current sheet....
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Do you want to compare A1 with A1 and A2 with A2 etc or do you want to look for A1 in one sheet in the whole A column in the other?

    If it's the latter try this formula in B1 sheet1 copied down

    =IF(COUNTIF('sheet2'!A:A,A1),"x","")

  4. #4
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    Thanks for replying back.
    I want to look for A1, A2 , A3, etc in one sheet in the whole A column in the other? this formula below you suggested didn’t work for some reason...It doesn’t mark an X where I planted the identical items.
    =IF(COUNTIF('sheet2'!A:A,A1),"x","")
    I copied the formula to all the cells but I either get an X in all the cells or an empty row.
    How come

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    The match has to be identical.

    Also, make sure your other sheet's name is Sheet2, otherwise change it in the fomrula to match the sheetname.

    Finally, make sure you are running calculations in Automatic mode....go to Tools|Options and ensure Automatic is selected in the Calculation tab.

  6. #6
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    I changed the sheet name is the formula. And I am running calculations in Automatic mode.

    I tried the formula on a smaller version and it still didnt work.
    I am using Excel 2003. The Compare b\w sheets is selected so I can see both of the sheets side by side.
    Here is a test:
    In sheet1 I have
    Column A
    Sara
    Mike
    Bob
    In cell B1 I have your suggested formula copies all the way through to cell B3

    Sheet 2
    Column A
    Sara
    Natan
    Mike
    George

    Sara & Mike in Sheet1 suppose to have a X next to them, right?
    What am I doing wrong?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I am not sure what you are doing wrong, if anything...

    See attached sample....
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    It's ok now. Thank you for sending an example.
    I appreciate your help.

  9. #9
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    One more question if I may,
    What if I am adding another sheet to compare with? How do I add that 3rd one to the formula you suggested?
    I might even have 5 sheets compare b\w.
    Thx

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by nemonat
    One more question if I may,
    What if I am adding another sheet to compare with? How do I add that 3rd one to the formula you suggested?
    I might even have 5 sheets compare b\w.
    Thx
    The simplest way would be to compare each sheet by stringing Countif's in an OR statement... If a match is found in any sheet, then the x is returned.

    e.g.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    Excellent. Thank you very much

  12. #12
    Registered User
    Join Date
    11-15-2007
    Posts
    9
    "If a match is found in any sheet, then the x is returned"
    How do I add that in the forumla?

    I get an #VALUE error when I try to use it like this:

    IF(OR(COUNTIF(Sheet2!A:A,A1),"x",""),COUNTIF('sheet3'!A:A,A1))

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    s/b

    IF(OR(COUNTIF(Sheet2!A:A,A1),COUNTIF('sheet3'!A:A,A1)),"x","")

+ 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