+ Reply to Thread
Results 1 to 10 of 10

Not sure I can get my TRIM formula to work or if it's something else

  1. #1
    Registered User
    Join Date
    11-06-2012
    Location
    Myrtle Beach
    MS-Off Ver
    Excel 2007
    Posts
    25

    Not sure I can get my TRIM formula to work or if it's something else

    Hi Everyone,
    The mystery today is: Why does a TRIM formula work sometimes and not others? I attached a spreadsheet if anyone wants to look at it if they're bored with tough questions.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Not sure I can get my TRIM formula to work or if it's something else

    If your data has come from the web it could include CHAR(160) which looks like a space.
    TRIM does not remove this character.
    You'll prob have to put the result in a SUBSTITUTE(A1,CHAR(160),"") or similar
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Not sure I can get my TRIM formula to work or if it's something else

    E16 is a number
    D16, ie TRIM(E16) is text
    You need to convert to numbers by using

    TRIM(E16)+0

    Do this and they'll all show up

  4. #4
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Not sure I can get my TRIM formula to work or if it's something else

    I changed column A and Column D to "Text" format and hey presto, it returns the Description.

    It's probably because Excel tries to work out if something is a number if you just have General format so it perhaps couldn't make the match.

    Give it a try on your version and post again if you found other instances.


    Excel is a constant learning process and it's great to help each other. If I've helped you today, a click on the star on the left is appreciated.

  5. #5
    Valued Forum Contributor
    Join Date
    01-08-2011
    Location
    Portsmouth, England
    MS-Off Ver
    Excel 2007 to 2016
    Posts
    456

    Re: Not sure I can get my TRIM formula to work or if it's something else

    SpecialK is right about the numbers, but some of your codes are combinations of letters and numbers so I guess you want them all as text.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Not sure I can get my TRIM formula to work or if it's something else

    Here's Microsoft's documentation for this issue: https://support.office.com/en-us/art...c-fe5303222c9d As mentioned above, the TRIM() and CLEAN() functions only remove certain subsets of the entire list of "non-printing" characters.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Not sure I can get my TRIM formula to work or if it's something else

    Quote Originally Posted by Special-K View Post
    Do this and they'll all show up
    Sorry, I didnt look that closely, am at work and it's near home time (!!)

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Not sure I can get my TRIM formula to work or if it's something else

    Your formula is unnecessarily long (too many sets of parentheses) and can be done like this instead:

    =IFERROR(IF(A6<1,"",INDEX($G$5:$G$25,MATCH(A6,$D$5:$D$25,0))),"No Definition")

    I can't see what the problem is, but it clearly doesn't like the result of the TRIM formula. Perhaps if you create a macro to get the unwanted spaces out of the original item number column?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Not sure I can get my TRIM formula to work or if it's something else

    Try this work-around...
    =IFERROR(IF(A5<1,"",INDEX($G$5:$G$25,IFERROR(MATCH(A5,$E$5:$E$25,0),MATCH("*"&A5&"*",$E$5:$E$25,0))))," No Definition")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Not sure I can get my TRIM formula to work or if it's something else

    Glad that worked for 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)

Similar Threads

  1. [SOLVED] Trim Function... does not work?
    By Doug929 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-06-2018, 01:00 PM
  2. TRIM function WONT WORK
    By danallamas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-28-2014, 12:11 AM
  3. [SOLVED] Vlookup doesn't work - even with TRIM function
    By piper_co in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-08-2013, 08:07 AM
  4. trim and vlookup dun work
    By Seeking help in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2006, 02:20 AM
  5. Trim does not work
    By Samantha in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2006, 08:10 PM
  6. 3 line code...my trim function doesnt work..
    By Piyush in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-01-2005, 12:13 PM
  7. using trim cmd. When I type this command it does not work. When I.
    By Rafiq in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2005, 10:06 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