+ Reply to Thread
Results 1 to 8 of 8

SUM Of Range of Values Based on Text String Matching Left and Right Characters

  1. #1
    Registered User
    Join Date
    11-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    Windows 7
    Posts
    25

    SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Hi All,

    Struggling with this one;

    I need to Sum a range of values from a column based on certain text values from another column.

    For example
    A B
    XW1AMB0A 20
    PMTABCP 5
    XW1ADC0A 30
    XW2AMN0P 10

    I want the SUM of the values in Column B based on the the first 4 characters in Column A being "XW1A" and the Last Character being "A" so in the example I would have a sum of 50. The text values are different lengths but the first 4 characters and the last will be always what Im looking for
    Originally I seperated the text out into separate columns and then used SUMPRODUCT using the two columns B containing "XW1A" and C containing "A" and teh values I wanted summing in D
    SUMPRODUCT(--($B$2:$B$33="XW1A"),--($C$2:$C$33="A"),($D$2:$D$33))

    That worked OK but now I want to reduce the Columns I use so I have tried to combine my original formula with the LEFT and RIGHT functions and failed, I'm not sure I can use the LEFT and RIGHT functions as Im trying to.! Example below;

    SUMPRODUCT(--($A$2:$A$33=(LEFT(A2,4)="XW1A")),--($A$2:$A$3314=(RIGHT(A2)="A")),($B$2:$B$33)

    I'm at a total loss so any help would be gratefully appreciated.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Maybe:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Try
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Now I think mine above will return wrong result...
    I like nflsales second solution

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Now I think mine above will return wrong result...
    I like nflsales second solution

  6. #6
    Registered User
    Join Date
    11-28-2014
    Location
    Birmingham, England
    MS-Off Ver
    Windows 7
    Posts
    25

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Thanks for your help zbor but Im going to use nflsales solution both of which are quite neat and like you I prefer the second one!

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Thanks you bjoanmark for your feedback and adding reputation

  8. #8
    Forum Contributor
    Join Date
    02-07-2013
    Location
    Karachi, Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: SUM Of Range of Values Based on Text String Matching Left and Right Characters

    Hi @bjoanmark,
    You have the solution FWIW.

    I think the formula you posted in OP is wrong or may be a typo:
    =SUMPRODUCT(--($A$2:$A$33=(LEFT(A2,4)="XW1A")),--($A$2:$A$3314=(RIGHT(A2)="A")),($B$2:$B$33))

    Regards,
    Khalid

+ 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] Error 13 when searching for string matching range values
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2016, 11:39 AM
  2. [SOLVED] IF text string is equal left characters and DDMM of DOB is outside a range.
    By DaveBre in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-07-2014, 06:53 PM
  3. Replies: 1
    Last Post: 07-24-2013, 05:18 AM
  4. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  5. Replies: 1
    Last Post: 01-16-2012, 04:03 AM
  6. removing 4 characters from the left of a string
    By mfish2010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2010, 07:16 PM
  7. Searching for Text String and copying specific portion based on characters
    By undergraduate in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2010, 12:45 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