+ Reply to Thread
Results 1 to 5 of 5

Sumif or vlookup on multiple partial strings

Hybrid View

  1. #1
    Registered User
    Join Date
    05-11-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    18

    Sumif or vlookup on multiple partial strings

    Hi

    Not sure what formula is required here so your help would be massively appreciated. I'm using 2007.

    I've attached a small spreadsheet example of what's required.

    I need to gather costs from a range of projects. In this example, I need to collect the Staff Costs into cell C20, from all of the projects codes in column A, which begin with TMOL.0001, i.e:

    TMOL.0001.01
    TMOL.0001.02
    TMOL.0001.03
    TMOL.0001.04

    So I think I need a formula to look at the partial range of the string "TMOL.0001" only, but will pick up all 4 of the projects.

    For single project codes, I'd use a sumif or vlookup which is fine for single look ups, but this is a multi look up, on a range of project codes containing some of the same string of characters.

    I realise a simple SUM range would also work, but this is not practical as the solution will be used across multiple (hundreds of) projects and I need make it the process automated. Additional projects will also be added with the same strings so I'll need to be able to capture them in future too..

    Help me, please




    ---------------------------------------------

    Updated...

    The solutions from Colin and Blake 7 below work perfectly, but...


    I'm pulling in data from three separate (private) spreadsheets into one consolidated (public) spreadsheet, using the SUMIF formula

    However the formulae do not work in the public file, unless the three private files are open.
    Apparently I need to use SUMPRODUCT for this to work when the other spreadhsets are closed.

    Please could someone recommend a SUMPRODUCT formula which will work with the attached, rather than SUMIF.

    Many thanks.
    Attached Files Attached Files
    Last edited by timjames; 09-01-2011 at 10:50 AM. Reason: Attachment added

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Sumif or vlookup on multiple partial strings

    Hi,

    There are three wildcards which can be used with SUMIF: * # ~

    * represents any number of character and is of interest to us here.



    This formula will sum B4:B13 when the cells in A4:A13 start with the text in C18.
    =SUMIF(A4:A13,C18&"*",B4:B13)

    So, if C18 contains TMOL.0001, it will sum any cells which start with TMOL.0001
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: Sumif or vlookup on multiple partial strings

    There are several ways of achieving this. See attached.

    My fave would be a pivot table. Please note that i have added an extra colum and named the projects. This way u can also use a sumif formula - also attached.

    Hi Colin - i didnt refresh! as an aside - what do the # and ~ wildcards do?
    Attached Files Attached Files
    Last edited by Blake 7; 09-01-2011 at 06:43 AM.
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Sumif or vlookup on multiple partial strings

    Hi,
    Hi Colin - i didnt refresh! as an aside - what do the # and ~ wildcards do?
    # represents any single character
    ~ means that the following character should be treated as a literal, not as a wildcard. So you use it when you're summing against cells which contain * or # or ~.

  5. #5
    Registered User
    Join Date
    05-11-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Sumif or vlookup on multiple partial strings

    Thank you both

    Colin, great simple solution.

    Blake 7 - Great name and suggestion of the pivot table.

    I'll be using both of your suggestions for different parts of this work.

    Many thanks!

    ********* UPDATED *************

    Please see my update above.
    Last edited by timjames; 09-01-2011 at 10:51 AM.

+ 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