+ Reply to Thread
Results 1 to 11 of 11

LEFT and SUMPRODUCT functions combined

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    20

    LEFT and SUMPRODUCT functions combined

    I have two columns of data that I need to use SUMPRODUCT on. However, in one of the columns, there might be text after the number. The text can be several different characters. I only want to use the numbers, never the text. Also, there are usually blank cells within Column B and at the bottoms of both columns because this formula is going into a template for future worksheets that all have differing numbers of rows.


    Example:

    14T 16
    40
    20 150
    97L 67
    13 12



    For the above example, I want the result to be 9879 (14*16 + 40*0 + 20*150 + 97*67 + 13*12 + 0*0 + 0*0 = 9879).

    I've tried using the LEFT function to only get the numbers before any text, but I can't make it work with the blank cells at the bottoms of the columns. Thanks for any help.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: LEFT and SUMPRODUCT functions combined

    Is there a pattern to the data in column A? Like, the number is always 2 digits? The text after the number is always a single letter?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    02-26-2014
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: LEFT and SUMPRODUCT functions combined

    Somewhat. Any number in Column A that also has text will always be 2 digits followed by a single letter. Any number that does not have text might be any number, never more than 3 digits (0-999).

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: LEFT and SUMPRODUCT functions combined

    Try this...

    Data Range
    A
    B
    C
    1
    -----
    -----
    -----
    2
    14T
    16
    9879
    3
    40
    4
    20
    150
    5
    97L
    67
    6
    13
    12
    7
    8
    9
    10


    This array formula** entered in C2:

    =SUM(IF(ISTEXT(A2:A10),LEFT(A2:A10,2),A2:A10)*B2:B10)

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  5. #5
    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: LEFT and SUMPRODUCT functions combined

    Or just SUMPRODUCT

    =SUMPRODUCT((LEFT(A2:A6,2)*(B2:B6)))
    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

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: LEFT and SUMPRODUCT functions combined

    Quote Originally Posted by AlKey View Post
    Or just SUMPRODUCT

    =SUMPRODUCT((LEFT(A2:A6,2)*(B2:B6)))
    You must have missed this:

    Any number that does not have text might be any number, never more than 3 digits (0-999).

  7. #7
    Registered User
    Join Date
    02-26-2014
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: LEFT and SUMPRODUCT functions combined

    Quote Originally Posted by Tony Valko View Post
    This array formula** entered in C2:

    =SUM(IF(ISTEXT(A2:A10),LEFT(A2:A10,2),A2:A10)*B2:B10)

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Yup. This formula worked. Thanks a lot!

  8. #8
    Registered User
    Join Date
    02-26-2014
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: LEFT and SUMPRODUCT functions combined

    Now, is there a way to write the formula so that the user doesn't have to use CTRL + SHIFT + ENTER when the formula is entered?

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: LEFT and SUMPRODUCT functions combined

    Maybe this:

    =SUM(INDEX(ISTEXT(A2:A6)*LEFT(A2:A6,2)*B2:B6,0))+SUMPRODUCT(A2:A6,B2:B6)

    But the SUM portion won't handle empty cells in column A.

    If you're concerned about users not re-entering the array formula as an array formula you can attach a reminder to the formula:

    =SUM(IF(ISTEXT(A2:A10),LEFT(A2:A10,2),A2:A10)*B2:B10)+N("Array Entered - CSE")

  10. #10
    Registered User
    Join Date
    02-26-2014
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: LEFT and SUMPRODUCT functions combined

    Ok, thanks.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: LEFT and SUMPRODUCT functions combined

    You're welcome!

+ 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. Sumproduct combined with Sum
    By Exceler in forum Excel General
    Replies: 3
    Last Post: 11-25-2010, 04:14 AM
  2. Combined Right with Left Formula problems
    By jj72uk in forum Excel General
    Replies: 4
    Last Post: 03-19-2010, 11:32 AM
  3. SUMPRODUCT combined with other functions
    By tweety127 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-13-2008, 12:30 PM
  4. Can Sumproduct and MAX/MIN be combined?
    By all4excel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-02-2008, 04:47 PM
  5. Combined Functions
    By fncuis in forum Excel General
    Replies: 4
    Last Post: 08-22-2005, 07:16 PM

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