+ Reply to Thread
Results 1 to 13 of 13

SUMIF Using Part of the contents of a cell

  1. #1
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    SUMIF Using Part of the contents of a cell

    Hello Gurus,
    I am trying to do sumif using parts of a cell as criterion.
    I have searched online and I know about this formula =SUMIF(Range,"*Part*",SumRange), however I noticed this only works when there is a space between the criterion and other contents of the cell. Eg "Part Excuse" but it does not work if we have it like this "Part/Excuse".

    What I need

    I have this template (see attached and below). This is the raw data.

    Product Code Location Quantity
    A01 12345/GAR 5
    A02 12346/GAR 8
    A03 12346/GAR 4
    A04 12345/GAR 1
    A02 12347/GAR 9
    A01 12346/GAR 5
    A04 12348/GAR 8
    A01 12347/GAR 7
    A02 12348/GAR 9
    A03 12345/GAR 3
    A04 12347/GAR 2
    A01 12348/GAR 5
    A02 12348/SUL 4
    A03 12347/SUL 7
    A01 12346/SUL 9
    A02 12347/SUL 8
    A03 12346/SUL 7
    A04 12347/SUL 6
    A02 12345/SUL 5
    A01 12348/SUL 3
    A04 12348/SUL 4
    A01 12345/SUL 6
    A03 12345/SUL 5
    A04 12346/SUL 7

    In my raw data, I have products with unique codes (here A01, A02, A03, and A04) with quantites but in different locations with unique codes (12345, 12346, 12347, and 12348). But each location has two or more sub-locations (GAR and SUL), therefore each sub-location is described as Location/Sublocation (12345/GAR, 12345/SUL, 12346/GAR, 12346/SUL, 12347/GAR, 12347/SUL, 12348/GAR and 12348/SUL).

    This data is automatically generated, so I cannot change the location code by putting space in between, besides the data is large.
    I need a formula that will be able to sum the data based on the product code and location code only (irrespective of the sub-location), that is, the location codes 12347/SUL and 12347/GAR should be generated in the same cell by reading only their common code "12347".

    Please find attached to see expected result.

    Thanks.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-12-2017
    Location
    Brazil
    MS-Off Ver
    2016
    Posts
    59

    Re: SUMIF Using Part of the contents of a cell

    Good Morning.
    See if the attachment helps you
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,133

    Re: SUMIF Using Part of the contents of a cell

    Try

    =SUMIFS('Raw Data'!$C:$C,'Raw Data'!$A:$A,$A3,'Raw Data'!$B:$B,B$1&"*")

  4. #4
    Registered User
    Join Date
    09-08-2016
    Location
    Rogers
    MS-Off Ver
    2013
    Posts
    13

    Re: SUMIF Using Part of the contents of a cell


  5. #5
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    Re: SUMIF Using Part of the contents of a cell

    Thanks Gfranco, John Topley and Lanceh.

    I think Gfranco/John Topley's formula helped better considering the weight of my data, but thanks all the same Lanceh. That is another formula I'd consider exploring.

    I appreciate all of you guys.

  6. #6
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    Re: SUMIF Using Part of the contents of a cell

    Hello Gfranco and John Topley,
    Sorry for bothering you again on this thread.
    In my raw data, there are some data I normally filter out before pasting and this is often tasking and laborious. So I am wondering if there is a way we can add an additional formula to disregard any data whose location ends with "/REC" irrespective of the product or any other thing so that we will still arrive at the same result as the previously solved one. This is just to save me of the time and effort I spend on filtering and manually removing those kinds of data.

    As you would see from the attached, the added data (those ending with "/REC" in the rawdata worksheet) has changed the result in H3:K6. However, I want the result to still remain the same way it was in B3:E6.

    Thanks.
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,242

    Re: SUMIF Using Part of the contents of a cell

    Just add another criterion thus:

    =SUMIFS('Raw Data'!$C$2:$C$28,'Raw Data'!$A$2:$A$28,$G3,'Raw Data'!$B$2:$B$28,H$1&"*",'Raw Data'!$B$2:$B$28,"<>"&H$1&"*"&"/REC")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  8. #8
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    Re: SUMIF Using Part of the contents of a cell

    Thanks so much AliGW. It worked perfectly.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,242

    Re: SUMIF Using Part of the contents of a cell

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  10. #10
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    Re: SUMIF Using Part of the contents of a cell

    Hi,
    Please kindly help with this also. I wish I understood the principles of the conditional SUMIFS using parts of cell contents.

    With the same data, I want a formula that adds this time around all the quantities of each product irrespective of their location. The only exception should be the ones that end with /REC.

    This is the expected result.

    Product Code Total Qty
    A01 40
    A02 43
    A03 26
    A04 28

    Thanks in advance.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,242

    Re: SUMIF Using Part of the contents of a cell

    Try this:

    =SUMIFS('Raw Data'!$C$2:$C$28,'Raw Data'!$A$2:$A$28,$G3,'Raw Data'!$B$2:$B$28,"<>"&"*"&"/REC")

    which removes references to the location.

    Before asking for further help, please try to understand the formula by examining it with the evaluate formula function in excel. Remember:

    =SUMIFS(sum_range,criteria_range_1,criteria_1,criteria_range_2,criteria_2,etc.)

  12. #12
    Registered User
    Join Date
    08-28-2014
    Location
    Nigeria
    MS-Off Ver
    2007
    Posts
    63

    Re: SUMIF Using Part of the contents of a cell

    Wow! I just noticed the major difference between SUMIF and SUMIFS. Never really paid attention to that difference prior to this time.
    Thanks.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,242

    Re: SUMIF Using Part of the contents of a cell

    Glad to have helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using cell contents as part of a VBA formula
    By olieshmade1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2015, 10:33 AM
  2. [SOLVED] Removing a part of the contents of a cell
    By alyaahmed in forum Excel General
    Replies: 11
    Last Post: 03-15-2014, 12:42 PM
  3. Cell Contents as Part Of Formula
    By outthere in forum Excel General
    Replies: 2
    Last Post: 07-23-2010, 01:47 PM
  4. IF statement that looks at part of the contents of a cell.
    By Jon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2005, 12:35 PM
  5. [SOLVED] Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 01:05 AM
  6. [SOLVED] Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 12:05 AM
  7. Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2005, 11:05 PM

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