+ Reply to Thread
Results 1 to 21 of 21

Adding numbers ignoring text & negatives

  1. #1
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Adding numbers ignoring text & negatives

    I wish to add a column of numbers with 2 complications: 1. some cells contain negative numbers which I want to treat as positive numbers and 2. some cells may also contain text which I want to ignore, but still add the number in the cell (in which case text is always the same word - online). I have a formula to treat the negative numbers as positive ( =SUM(ABS(T3:T19)) ), but can't work out how to also include the numerical data in cells with text. In row '11' below I have shown the results I would like to generate.

    Any help appreciated! Thx
    Attached Files Attached Files

  2. #2
    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
    30,730

    Re: Adding numbers ignoring text & negatives

    TRY

    =SUM(IF(NOT(ISNUMBER(A1:A9)),ABS(--SUBSTITUTE(A1:A9,"online","")),ABS(A1:A9)))

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

  3. #3
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Thanks John. That gives me #VALUE! - have I copied it wrong maybe?!

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Adding numbers ignoring text & negatives

    Or only this?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 09-10-2022 at 08:53 AM.

  5. #5
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Thanks - it wont let me input that formula - I get the error message - 'There's a problem with this formula...' box..?

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Adding numbers ignoring text & negatives

    And if you try to copy the formula from the sheet?

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,605

    Re: Adding numbers ignoring text & negatives

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

  8. #8
    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
    30,730

    Re: Adding numbers ignoring text & negatives

    Se attached with answers from Hans and Pepe
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    For some reason I cant open the sheet you've attached - even if I download it first...

  10. #10
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Oooh! That works perfectly in my example but for some reason when I copy it over it doesnt! Could it be that there are some blank cells in the 'real' sheet?

  11. #11
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Quote Originally Posted by JohnTopley View Post
    Se attached with answers from Hans and Pepe
    Thanks I can see that and both work... One added complication is that some cells in the 'actual' sheet are blank - and when I copy it over (or create blank cells in the example) it doesnt like it. Im guessing thats easier to work around?

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Adding numbers ignoring text & negatives

    That works perfectly in my example but for some reason when I copy it over it doesnt! Could it be that there are some blank cells in the 'real' sheet?
    If you add a sheet then I can tell.
    Without a sheet, the most likely cause of a #VALUE error in ABS or SUM is that there is a cell that does not contain a numeric value and is not "online", as indicated in post #1.
    Or a cell with a space is involved. SUM can handle that, but ABS can't.

    Furthermore, the request to consider add reputation request to any helpers' answers that you think deserve.
    This can be done by clicking * Add reputation at the bottom left of the answer.

  13. #13
    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
    30,730

    Re: Adding numbers ignoring text & negatives

    @Hans: the #Value is caused by a blank cell.

  14. #14
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Thanks again for all the help with this!! One final question - is there a way of adapting either of the formulas to ignore empty cells? Ive tried a couple of things with my limited excel knowledge - wondering if that a formula too many?! Thanks

  15. #15
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Adding numbers ignoring text & negatives

    The #VALUE in my formula is NOT caused by a blank cell.

    The SUM functions ignores blank cells (only if no cells left, SUM replaces 1 blank cell by zero) before executing SUM.
    The ABS function replaces a blank cell by zero before executing ABS.
    Because of how these functions work in this way, a blank cell cannot cause #VALUE in SUM or ABS.

    I indicated in post #12, what could be the cause of a #VALUE.
    If you upload your sheet I can check if that is the case.
    Last edited by HansDouwe; 09-12-2022 at 05:53 AM.

  16. #16
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Thanks Hans- this is the relevant part of the actual sheet. Im playing around with V-Y 24.
    Attached Files Attached Files

  17. #17
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,864

    Re: Adding numbers ignoring text & negatives

    Try the following array entered formula** in cell V24:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  18. #18
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Adding numbers ignoring text & negatives

    Or try

    =SUM(IF(V3:V19="","",ABS(SUBSTITUTE(V3:V19,"online",""))))

    Ctrl+Shift+Enter.

  19. #19
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Quote Originally Posted by JeteMc View Post
    Try the following array entered formula** in cell V24:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Let us know if you have any questions.
    Amazing!! Thanks so much! This will make such a difference to what I'm trying to do & I could never have got here myself!!

  20. #20
    Registered User
    Join Date
    09-10-2022
    Location
    UK
    MS-Off Ver
    Mac
    Posts
    10

    Re: Adding numbers ignoring text & negatives

    Quote Originally Posted by Phuocam View Post
    Or try

    =SUM(IF(V3:V19="","",ABS(SUBSTITUTE(V3:V19,"online",""))))

    Ctrl+Shift+Enter.
    Thanks v much - this forum has been so helpful!

  21. #21
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,864

    Re: Adding numbers ignoring text & negatives

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. Trying to add a column of numbers, but ignoring negatives
    By Lord Waste in forum Excel General
    Replies: 5
    Last Post: 04-07-2009, 06:43 AM
  2. Sort ignoring negatives and positives
    By bangbanjo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-08-2005, 11:05 AM

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