Share via

Why the =SUBSTITUTE(A1,CHAR(160),"")+0" formula to remove space from the end of a value is not working?

Anonymous
2023-12-20T14:07:26+00:00

I have been using the "=SUBSTITUTE(A1,CHAR(160),"")+0" formula to remove space from the end of multiple values for monthly reports on Excel for a long time, previously on a Windows-based computer and for the past year on a Mac. It always worked until recently. The same formula is only returning with the #VALUE! error. I tried to replace the CHAR(160) with CHAR(32) and also the SUBSTITUTE function with TRIM. Tried everything but it's not coming back with the desired result as I used to get it before. It's either giving the #VALUE! or giving the value back with space, which means no formula is going to work on the value coming back with a space. What am I missing?

Microsoft 365 and Office | Excel | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2023-12-20T21:35:53+00:00

    HansV wrote:

    Try this formula:

    =--SUBSTITUTE(B2,CHAR(160),"")

    or

    =VALUE(SUBSTITUTE(B2,CHAR(160),""))

    The result should be no different from =SUBSTITUTE(B2,CHAR(160),"")+0 , which is what we see in K2.

    And in fact, if I simply cause K2 to be recalculated, it works just fine on my computer.

    Therefore, I suspect the problem is: Shazia's computer (or Excel instance) does not interpret the string "48,278" as a number after removing the last character (!).

    So, it seems that comma is not treated as either the decimal point or the thousands separator (!).

    Quick-and-dirty work-around: Deselect the Advanced Option "Use system separators", and set the "Decimal separator" option to period (dot), and set the "Thousands separator" to comma, or vice versa.

    EDIT.... If comma should be interpreted as the thousands separator, as simpler alternative might be change the formula in K2 as follows (adding some generalization):

    =--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LEFT(B2, LEN(B2)-1), ",", ""), CHAR(32), ""), CHAR(160), "")

    That removes the comma, any and all normal and nonbreaking spaces, and the last character, then converts to a number.

    And alternatively, if you know the comma should be a different character, replace the first red-highlighted null string ("") with the replacement character in double-quotes (e.g. ".")


    PS.... If that does not work around the problem, there might some other inexplicable problem with Excel on your computer. Ostensibly, that might mean that you need to repair or reinstall your Office product.

    But before you try that draconian (and risky) procedure, try the following experiment. Close all instances of Excel. Then in a new instance of Excel, manually type 48,278 into A1 (with the comma). What does =ISNUMBER(A1) return? If TRUE, what does =INT(A1) return?

    Also, manually type =VALUE("48,278") into A2. What does it return?

    And again, before you try to repair or reinstall Office, review your computer configuration. And if you are using cloud services or online Office 35, try to review their relevant configuration. (I don't know much about that.)

    2 people found this answer helpful.
    0 comments No comments
  2. HansV 462.6K Reputation points MVP Volunteer Moderator
    2023-12-20T22:32:53+00:00

    You're correct (of course)!

    0 comments No comments
  3. HansV 462.6K Reputation points MVP Volunteer Moderator
    2023-12-20T19:57:13+00:00

    Thanks! Try this formula:

    =--SUBSTITUTE(B2,CHAR(160),"")

    or

    =VALUE(SUBSTITUTE(B2,CHAR(160),""))

    0 comments No comments
  4. Anonymous
    2023-12-20T18:20:21+00:00

    Hi there, the copy of the workbook can be accessed through the following link:

    MACROS_Monthly Flash Report.xlsm

    Many thanks

    0 comments No comments
  5. HansV 462.6K Reputation points MVP Volunteer Moderator
    2023-12-20T14:19:17+00:00

    Could you create a stripped-down copy of the workbook demonstrating the problem (without sensitive information) and make it available through one of the websites that let you upload and share a file, such as OneDrive, Google Drive, FileDropper or DropBox. Then post a link to the uploaded and shared file here.

    0 comments No comments