+ Reply to Thread
Results 1 to 3 of 3

Countif and Hlookup

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010, Excel 2011 for mac
    Posts
    82

    Countif and Hlookup

    Hi,

    I have a hlookup function in column A, extracting ID's from another sheet in specified rows. This works fine. function shown below

    A1: =HLOOKUP("ID";'sheet2'!$1:$968;2;FALSE)

    This returns
    A1: AT

    In column B I want to count the number of occurences of the result from A1 in a certain column in sheet2, so I figured I could use countif

    B1: =COUNTIF('sheet2'!R$2:R$1000;A1)

    This, however, returns
    B1: 0

    If I insted write out
    B1: =COUNTIF('sheet2'!R$2:R$1000;"AT")
    Excel returns,

    B1: 4

    Any ideas to why this is and how to fix it?

    Any help is very much appreciated

    regards,
    Kbka

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,232

    Re: Countif and Hlookup

    It would probably help to see the workbook or a typical sample of the structure and data.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,412

    Re: Countif and Hlookup

    Perhaps the AT in A1 has a space at the end of it which you can't see. You can check this by putting =LEN(A1) in a blank cell, which will tell you the number of characters in A1. You can use TRIM( ... ) around your formula in A1 to remove any excess spaces.

    Hope this helps.

    Pete

+ 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