+ Reply to Thread
Results 1 to 24 of 24

Using SUM with Find

  1. #1
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Using SUM with Find

    Hi,

    What I'm tryn to do is check if and cell in a range contains the letter "P" and some value after "P" so like "P4".
    If it does then SUM the value from this cell so I'm guessing the LEFT funcion should be used.
    But I don't know how to combine this into a working formula
    Please help.

    Example is like this:
    Search the range B4:AF4 if it contains a value "P" and some number after "P" then SUM those values.
    But if it only contains "P" and no value after it then just skip it.

    Cell value example:
    D4 = "P"
    E4 = "P2"
    H4 = "P4"
    So the sum of these values would be
    AI4 = "6"

    Hope someone understands this

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Using SUM with Find

    Hi.

    Try this function. Called the function in cell AI4:

    temp.xlsm
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Using SUM with Find

    hi stojko89, nice to see you again. an alternative:
    =SUMPRODUCT((ISNUMBER(SEARCH("P",B4:AF4)))*(SUBSTITUTE(B4:AF4,"P",0)))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  4. #4
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Using SUM with Find

    In D5

    =IFERROR(SUM($C5:C5,IFERROR(IF(SEARCH("P*",D4),RIGHT(D4,LEN(D4)-SEARCH("P",D4))+0),"")),"")

    R's
    Amit Kumar

  5. #5
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Hello,

    Thanks for your answers but:
    jraj1106 - I don't want to use a macro (don't know why) but if I use a macro for this I can also use it for every thing else and I don't want that lol (I'm strange about this some times hehe)
    benishiryo - nice to see you again too but the code doesn't work gives me back an error.
    amitkr3855 - youre code doesn't work either.

    I'm thinking of a code that would go some how like this:
    Find P in the range B4:AF4 and then sum the values by the P. The values are maximum 2 numbers.
    So if values are like this for example:
    D4 = "P"
    E4 = "P2"
    H4 = "P4"
    O4 = "P10"

    AI4 is the sum of these values so 16

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    Array formula - Requires Ctrl+Shift+Enter

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


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  7. #7
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Sixthsense thanks! that works
    But could you explain this to me:
    Please Login or Register  to view this content.
    I know that Left Trim....checks if theres a "V" in the cell but whats with the *ISNUMBER?
    ISNUMBER checks if the other trimmed part is a number that I get but why do you use the * between?

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    @ stojko89,

    Glad it helps you and thanks for the feedback

    The trim function is used what happens if the data after P possess leading and trailing spaces like this
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    So using Trim will make the data like
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    using mid function =MID("P 25",2,255) will result the data as SPACE25 like this
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    using SPACE25*1 will convert it as real number
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    using the converted value isnumber(25) will check and ensure whether it is number (i.e.) isnumber("Abc")

    Finally * operates as AND operator in ARRAY FORMULA'S.

    Hope it is clear

  9. #9
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Ohhh ok thanks for the explenation and the help, sory I can't give you more that one * Rep.
    If I could I would ask for one more thing tough?

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    You are welcome and thanks for the rep

    If your next question is something related to this thread then you can continue with this thread or create a new thread

  11. #11
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    It's related becuse it contins the formula you just gave me with a different fix.
    So I had my formula and I combined your formula with mine.
    But since I have more text then just "P" I also have "V" and "H" I used the ISTEXT function.
    And here is my formula now.
    But the problem is that insted of getting the value 14 I get 15 when it counts my 4th row.

    Please Login or Register  to view this content.
    Any idias?

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    I am not sure what the below conditions are doing and what is the purpose of these code's
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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


    Have you entered it as array formula?

  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    It's entered as an array formula.
    Here is the workbook I have.

    i have explained inside what each column counts or should count or sum.
    Attached Files Attached Files

  14. #14
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    So since the value was 15 instead of 14 I've tryed putting -1 in the formula and it works:
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    So the formula like this:
    Please Login or Register  to view this content.
    Works fine now I Guess...unless you have any other idias

  16. #16
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Nah...it doesn't work correctly for other months just for this one

  17. #17
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    I gone for lunch and now I am back now I will have a look in your file

  18. #18
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    If you don't mind can you please show the expected output, because the column headers are in some other language so I am confused what the data's are and what needs to be arrived

  19. #19
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    This is going to be hard to explain hehe but I'll try to writte it down. Give me 5min.

  20. #20
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Ok so here goes
    Please let me know if you understand what I'm tryn to do.
    Columns AG,AH and AJ work as they should.
    Cell AK3 also works as it should the only column that I have problem with is AI for each row.
    It should count like this:
    All present hours (8,9,11,...) <---this is how many hours I'm present that day.
    Plus all numbers after a letter (P8, P3, V3, V8,...)
    Plust Vacations days * 8 so we get hours out of that
    All that minus the hours that are possible present hours till that day <---- thats why I use the countblank cell function.
    Attached Files Attached Files

  21. #21
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Here is the short version of the story:
    This part of the code:
    Please Login or Register  to view this content.
    Returns value 9 instead of 8 for cells B4:AF4.
    It should retrun value 8 because the only cell in that rage that contains a number after the letter is I4 and the value after the letter is 8.

  22. #22
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    This part is the error part of your formula ISTEXT(LEFT(

    Left converts Numeric Value as Text Value the H4 cell value 11 has been converted into "11" because of left function. =Left(H4,1) result as "1" so it treated as text and the another 1 is getting added so it is resulting as 9 instead of 8.

  23. #23
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Using SUM with Find

    Haha! so I'm just using SUM(IF(ISTEXT(B4:AF4)*ISNUMBER and it works!!!
    Yeiiii
    Thanks a lot!

    Now it's finaly solved hehe

  24. #24
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Using SUM with Find

    Glad it helps you and thanks for the feedback

+ 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