+ Reply to Thread
Results 1 to 5 of 5

formula with wildcard

  1. #1
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415

    formula with wildcard

    hi guys
    thanks to nbvc i have this formula
    Please Login or Register  to view this content.
    but the trouble is i need it to understand there may be wildcards

    ie

    input sheet g1 has the word "york" in it ( without the quotes )

    however the results in columns d and h
    may suggest "york city"

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

    Re: formula with wildcard

    in which case use SEARCH

    =SUMPRODUCT(--(ISNUMBER(SEARCH('input sheet'!$G1,'head to head'!$D$1:$D1000))),--(ISNUMBER(SEARCH('input sheet'!$G1,'head to head'!$H$1:$H1000))))

    NOTE:

    I revised D:D to D1:D1000 and H:H to H1:H1000 ... try to restrict the ranges you are working with else performance will be affected.
    Also if you were to try and run the entire column reference version pre XL07 you would get an error (I know you're running 2007 but worth a mention for others)

  3. #3
    Forum Contributor
    Join Date
    01-06-2009
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    415

    Re: formula with wildcard

    thanks donkeyote
    that all makes sense
    would it make it entirely better if i narrowed it down further to just the rows with data?

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

    Re: formula with wildcard

    In retrospect assuming your lookup value is always a complete word -- ie Arsenal and not **** for Arsenal & Tottenham rather than Tott for Tottenham Hotspur then the below is a little more robust:

    =SUMPRODUCT(--(ISNUMBER(SEARCH('input sheet'!$G1&" ",'head to head'!$D$1:$D1000&" "))),--(ISNUMBER(SEARCH('input sheet'!$G1&" ",'head to head'!$H$1:$H1000&" "))))

    It adds a space to the G1 value and does likewise for all the values in the lookup columns.. in doing so it will ensure it only looks for "York " ... so if you had say a team called "Yorksters" when searching "York" for York City "Yorksters" would be ignored... ie it searches for "York " ... "Yorksters" does not meet that criteria whereas "York City" does...

    Hopefully that makes some sense.

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

    Re: formula with wildcard

    In relation to your other thread... given you're using 2007 you can dispense with Sumproduct altogether and use COUNTIFS (quicker)

    =COUNTIFS('head to head'!$D$1:$D$1000,'input sheet'!$G1&" *",'head to head'!$H$1:$H$1000,'input sheet'!$G1&" *")

    Note: COUNTIFS is not backwards compatible with earlier versions of Excel.

+ 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