+ Reply to Thread
Results 1 to 10 of 10

SUMIF & Split Strings

  1. #1
    Registered User
    Join Date
    01-15-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2011
    Posts
    7

    SUMIF & Split Strings

    Hello!

    If the attached screen shot works:

    Aim: In F5 add all values from column B that are linked to 'A' in column A.
    In F6 add all values from column B that are linked to 'B' in column A.
    In F7 add all values from column B that are linked to 'C' in column A....and so on.



    My problem:

    In column B I have used =RIGHT( A5, LEN( A5 ) - FIND( " ", A5 ) ) to separate the string from column A, so the SUMIF function returns an empty cell.


    If I enter the text manually (without splitting the string) SUMIF works, is there away around this?

    All help, greatly appreciated. Thank-you in advance.Screen Shot 2015-01-15 at 7.30.11 pm.png
    Last edited by JimmyT10; 01-15-2015 at 05:40 AM. Reason: Adding image

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: SUMIF & Split Strings

    Try

    =SUMPRODUCT((LEFT(A$5:A$16,1)=E5)*(B$5:B$16))
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: SUMIF & Split Strings

    Try

    =SUMPRODUCT((LEFT(A$5:A$16,1)=E5)*(B$5:B$16))

    NOTE: With the data you've supplied you can shorten your routine in column B to

    =RIGHT( A5, LEN( A5 ) - 2 )

    though I suspect this will not work with the actual data as the "A" in "A 2239" will probably change to something longer

  4. #4
    Registered User
    Join Date
    01-15-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2011
    Posts
    7

    Re: SUMIF & Split Strings

    Thanks for the swift reply!

    Unfortunately when pasted in F5 - returned #value - error in formula.

    Unlike excel, I don't assume it's you who made the mistake, have I made a newbie error here somewhere?

  5. #5
    Registered User
    Join Date
    01-15-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2011
    Posts
    7

    Re: SUMIF & Split Strings

    Indeed, 'A' is a stand in. Got it finding the first 'space' in the string.

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: SUMIF & Split Strings

    Maybe this will work for you better

    in B5 and copy down

    =IFERROR(IF(LEFT(A5,FIND(" ",A5)-1)=E5,--RIGHT(A5,LEN(A5)-FIND(" ",A5)),0),0)

    then in F5 and copy down

    =SUMIF($E$5:$E$16,E5,$B$5:$B$16)

    The solution could've been different with different layout.

    Row\Col
    A
    B
    C
    D
    E
    F
    4
    Custormer 1 Values SUM
    5
    A 2239
    2239
    A
    2878
    6
    B 560
    560
    B
    907
    7
    C 711
    711
    C
    1238
    8
    D 907
    907
    D
    1814
    9
    E 560
    560
    E
    1036
    10
    0
    11
    Customer 2
    0
    12
    A 639
    639
    A
    13
    B 347
    347
    B
    14
    C 527
    527
    C
    15
    D 907
    907
    D
    16
    E 476
    476
    E
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    01-15-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2011
    Posts
    7

    Re: SUMIF & Split Strings

    Hi Al,

    Thanks for your help here. A bit more clarification here if you wouldn't mind.

    Screen Shot 2015-01-16 at 6.50.11 pm.png

    I've got you solution working pretty well on my test sheet, as seen here.

    But the letters 'A, B, C, D, E' are stand in for customer names, 'Smith&Son' for example. Most have a different number of letters in their name. Is there something in this =IFERROR(IF(LEFT(A5,FIND(" ",A5)-1)=E5,--RIGHT(A5,LEN(A5)-FIND(" ",A5)),0),0), that specifically tells excel to look for on letter that would be stopping it working in my main sheet?

    I used split string =RIGHT( A5, LEN( A5 ) - FIND( " ", A5 ) ) to search for the space (which is constant) and return everything after it.


    Hope you can help again.
    Attached Images Attached Images

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: SUMIF & Split Strings

    Dear Jimmy,
    Unfortunately, I can't always guess what one need or want. As a requester, it is your responsibility to provide information as accurate as possible. Otherwise you and I, both wasted our time.

    Please attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

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

    Re: SUMIF & Split Strings

    Based on the data in your first post, try using this formula in B5 copied down to extract the number as a numeric value

    =REPLACE(A5,1,FIND(" ",A5),"")+0

    Then F5 can just be a SUMIF formula using a wildcard

    =SUMIF(A:A,E5&" *",B:B)

    This works for customer names of any length, assuming the names themselves don't contain spaces
    Audere est facere

  10. #10
    Registered User
    Join Date
    01-15-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2011
    Posts
    7

    Re: SUMIF & Split Strings

    Apologies Al. New to this. Didn't mean to waste your time.

    Thank-you daddylonglegs! This has worked.

+ 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. [SOLVED] Split alphanumeric strings into three different columns.
    By SamCV in forum Excel General
    Replies: 4
    Last Post: 03-01-2014, 02:38 PM
  2. Split Strings Into Columns Based On Repeating Characters - Macro
    By jessekanclerz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2013, 11:13 AM
  3. using the split function on an array of strings
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2013, 12:52 AM
  4. [SOLVED] 2010: random length strings in cell - need to split
    By dhipwood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-30-2012, 11:46 AM
  5. Text strings with sumif
    By martinjones23 in forum Excel General
    Replies: 3
    Last Post: 12-17-2009, 11:56 AM

Tags for this Thread

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