Forum Discussion

philip369's avatar
philip369
Copper Contributor
Dec 05, 2019

Impossible to sum numbers in Excel

I hope someone can help with this because I am pulling my hair out. 

When I try to sum numbers in a column, at the bottom of the page it gives me a count and not a sum. 

When I try to Autosum, it gives me =SUM(). 

When I try to add the specific cells, e.g.  =SUM(E2:E15) it gives me zero. 

 

I've read through multiple forums which suggest to make sure the cells are formatted as numbers- which they are. 


Could someone help me out here because I am completely at a loss. Thanks. 

  • philip369 

    If your numbers are formatted as Text, changing the formula of existing numbers as General or Number won't change them back to real numbers.

     

    To easily convert numbers entered as Text back to the real numbers, select the numbers and follow these steps...

     

    1) Go to Data Tab.

    2) Click on Text to Columns and click on Finish in the next window which pops up which is Text to Columns wizard window.

     

    As a result, your numbers as Text will be converted into the real numbers and your existing Sum formula will return the correct output.

    • davidelkinsrice's avatar
      davidelkinsrice
      Copper Contributor
      Bless you for your response. This has driven me crazy for a very long time. In the old days spreadsheets would let you add numbers regardless if it was text or a number (because that is the whole purpose of a spreadsheet :-D). Thank you so much for elucidating me on how to fix this ridiculous problem.
    • Leonox's avatar
      Leonox
      Copper Contributor
      That worked for me, thank you!
    • philip369's avatar
      philip369
      Copper Contributor

      Riny_van_Eekelen Yes... like I said I have selected the cells and marked them as numbers... but that doesn't change anything.  Grrr.

      • Riny_van_Eekelen's avatar
        Riny_van_Eekelen
        Platinum Contributor

        philip369 

         

        Understand! But if you format a text as a NUMBER it will still be a text and the SUM function will not work. Say you have "  10" in A1. This a is a text. Try entering the formula =VALUE(A1) to make the text that looks like a number into a real number. Otherwise, upload you workbook so that I can have a look at it.

         

         

    • Lena1987's avatar
      Lena1987
      Copper Contributor

      Riny_van_Eekelen or anyone else I have the same problem, and I cant get it fixed, can I maybe give my excel sheet to you so you can check? I got the excel sheet from another program (YOCO) and have tried all the suggestions..

      Regards

      Lena

  • DrDave990's avatar
    DrDave990
    Copper Contributor

    philip369  I had the same problem when cutting and pasting from a web page. Numbers were text. All I did was a Replace of space to @ then replace the @ with nothing. Trying to replace space with nothing did exactly that - nothing - it didn't remove the spaces. 

    Text to columns did nothing, I have yet to come across anything where that function works to be honest and I've been using Excel since it came out (I'm an old programmer!).

    • SergeiBaklan's avatar
      SergeiBaklan
      MVP

      DrDave990 

      copy/pasting from web usually adds non breaking space (char code 160), which is not printable character. You may check with =LEN(A1) and compare with number of visible characters.

      On 365 or 2021 you may check exact codes with =CODE( MID( A1, SEQUENCE(LEN(A1), 1) ).

      Or rightmost code as =CODE( RIGHT(A1) ). In general it could be other non-printable characters. If they are you may remove them

      =1*SUBSTITUTE(A1, CHAR(160), "" )

      with 1* to convert result to number.

  • terryloo's avatar
    terryloo
    Copper Contributor
    That's because a hidden character somehow snuck in the numbers and prevents you from using those as numbers. CHAR(0160) didn't work for me.

    Only 100% foolproof way that I found was to
    1) save the excel file as a *.txt
    2) open the txt file, select the whole file (CTRL + A), the hidden text characters will now appear as ?
    3) Find replace ? with nothing.
    4) Copy paste the whole thing back to excel.
    • PeterBartholomew1's avatar
      PeterBartholomew1
      Silver Contributor

      This is a discussion that seems to go on forever!

       

      Another option, that has come about recently, is to forget about characters you do not want and focus on extracting those you require.  For a single cell you might have

      = VALUE(CONCAT(REGEXEXTRACT(@import, "(\d|\.|-)+", 1)))

      but for an entire array of imported data,  this becomes,

      = MAP(
           import,
           LAMBDA(data,
              VALUE(CONCAT(REGEXEXTRACT(data, "(\d|\.|-)+", 1)))
           )
        )

      Life gets more complicated if you need to pick out dates, numbers in scientific notation etc.

  • terryloo's avatar
    terryloo
    Copper Contributor

    philip369 

    I realise that people keep arguing about this issue so here's some test data that we received from a Powerpoint table.

     

    NB
    73​
    49​
    29​
    68​
    104​
    52​
    122​
    22​
    66​
    73​
    56​

     

    Here's the ultimate solution.

    1) Your numbers are likely saved as text and excel needs to be reminded to process them as numbers.

    * If it is a single cell and there's a green triangle in the upper corner, try clicking on it and convert it manually.

    * If it is a column of numbers, your first instinct should be to use the "Text to Columns" tool to change the data type into standard. Select the column > Data Tab > Text to Columns > Finish.

    * If it's a whole table, use the "Text to Columns" tool, column by column.

     Select the column > Data Tab > Text to Columns > Finish.

     

    2) If the above doesn't work, your numbers probably have a hidden character somewhere which forces excel to consider them as text. To know if there are any hidden characters in cell A1

    * Click on B1 > Type formula =LEN(A1) and if there is a difference between the characters you see and the number of characters written in B1 then you'll know that there's some shenanigans somewhere. The likely culprit is CHAR(160) which is both invisible and unselectable but it's not always the case. 

    You can use =TRIM(CLEAN(A1)) to try and find the hidden characters or use VBA/Powerquery but not all of them are destroyed and some hidden characters might escape detection

     

    If all else fails, copy the offending data into another excel sheet and save as Tab Delimited Text (. txt)

    It will save all data into UTF-8 and show the hidden characters that are causing the issue. Be warned as it replace all formulas into their corresponding result. 

     

    Using the above example, you should have this as a result:

    NB?
    73?

    You can then proceed to replace the "?" by "" using CTRL + H, then paste back the values into your excel sheet.

     

    3) Someone else has mentioned using a Python Script to clean the table but not everyone has access to it and I am pretty sure that it will depend on a case-to-case basis. 

     

    In any case, I hope it helps.
    If someone has a better solution, I would be very interested to hear about it. I have enclosed the offending columns in my answer.

    • davidmgahan's avatar
      davidmgahan
      Copper Contributor

      I'm having a similar issue where an exported excel file will not sum up for me. I've tried multiple steps above and from other chats to no avail.
      Would someone be able to help me by looking at this sheet?

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        davidmgahan 

        Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?

  • philip369 

    A different strategy would be to accept the values as text, potentially with embedded hard spaces, currency symbols, comma group separators etc, and use a Lambda function to strip out unwanted characters and put the pieces together once more as numbers.

    "Worksheet formula"
    = SUMTEXTλ(out) 
    
    "where the function is:"
    SUMTEXTλ = LAMBDA(text, 
        SUM(
            IFERROR(
                BYROW(text, LAMBDA(x,
                    VALUE(CONCAT(REGEXEXTRACT(x, "(\d|\-|\.)+",1)))
                )),
            0)
        ));

    IFERROR is intended to pick up the situation where there are no numbers in a text string.

Resources