+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : COUNTIFS with LEFT - workaround needed

  1. #1
    Valued Forum Contributor
    Join Date
    06-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    341

    COUNTIFS with LEFT - workaround needed

    Hi,

    I am trying to run a COUNTIFS formula with a LEFT condition on an array.
    I know that LEFT cannot be combined with COUNTIF as well as COUNTIFS.

    The workaround for COUNTIF with LEFT is to use SUMPRODUCT, but since I am using COUNTIFS and there is no such thing as SUMPRODUCTS, I am a bit stumped as to how I should go about it.

    Formula I am trying to use:
    =COUNTIFS(WEH.xlsx!$BH:$BH,$H$2,LEFT(WEH.xlsx!$BB:$BB,4),LEFT($A$2,4))

    I know I can replace the second portion with
    =SUMPRODUCT(--(LEFT(WEH.xlsx!$BB:$BB,4)=LEFT($A$2,4))), but it wouldn't be combinable with COUNTIFS as far as I can work out.

    I would just add a helper column to the WEH workbook except that the number of LEFT characters differs based on where in A:A they are (some names are shorter than 4, so I need to change it to exact match for those names, I can't do this with WEH because it would require manual changes for every entry with a name less than 4 characters)

    Please help

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIFS with LEFT - workaround needed

    You can use multiple conditions within SUMPRODUCT so try

    =SUMPRODUCT(--(WEH.xlsx!$BH:$BH=$H$2),--(LEFT(WEH.xlsx!$BB:$BB,4)=LEFT($A$2,4)))

    [although it's not advisable to use whole columns with SUMPRODUCT, it'll make it rather slow]

    or, better, you can use a wildcard with COUNTIFS assuming the data isn't numeric, i.e.

    =COUNTIFS(WEH.xlsx!$BH:$BH,$H$2,WEH.xlsx!$BB:$BB,LEFT($A$2,4)&"*")
    Audere est facere

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIFS with LEFT - workaround needed

    Also maybe watch how you reference the other workbook.
    =SUMPRODUCT(--(LEFT([WEH.xlsx]Sheet1!$BB$2:$BB$1000,4)=LEFT($A$2,4)),--([WEH.xlsx]Sheet1!$BH$2:$BH$1000=$H$2))
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Valued Forum Contributor
    Join Date
    06-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    341

    Re: COUNTIFS with LEFT - workaround needed

    Thanks worked great - only had text luckily :D

+ 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