+ Reply to Thread
Results 1 to 8 of 8

To fix a formula that is giving the wrong data

  1. #1
    Registered User
    Join Date
    06-23-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    16

    To fix a formula that is giving the wrong data

    I am working with a list of names that are separated by a space following a semicolon.
    The formula I have allows me to sort within a cell alphabetically and another formula that is supposed to remove the semicolon after the last name. The problem is the formula fails to remove the semicolon and adds a letter at the end of all the names.

    This is what I am getting when I execute the formula comes out as this
    "Adam;Y Kayla;Y Meghan;;Y Xavier;Zola;Y Yang;Y"

    I do not want double semicolon Y after Meghan. I want to remove the letter and the semicolon at the end of the last name. I only want the names sorted alphabetically, separated by a semicolon following space, and no space or semicolon at the end of the last name.

    I am trying to get the names sorted alphabetically within a cell and remove the semicolon at the end of the last name.

    I have attached an excel file to show as an example.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: To fix a formula that is giving the wrong data

    Look for the differences
    Attached Files Attached Files
    Messages have been translated from Dutch to English by means of google translate.

  3. #3
    Registered User
    Join Date
    06-23-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    16

    Re: To fix a formula that is giving the wrong data

    Quote Originally Posted by Vraag en antwoord View Post
    Look for the differences

    Hello Vraag en antwoord,

    I am confused what do you mean by the difference?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: To fix a formula that is giving the wrong data

    Try this...

    =TEXTJOIN("; ",TRUE,SORT(FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(A1,";","")," ","</B><B>")&"</B></A>","//B")))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: To fix a formula that is giving the wrong data

    Duhh. Scrap that, use this..

    =TEXTJOIN("; ",TRUE,SORT(FILTERXML("<A><B>"&SUBSTITUTE(TRIM(SUBSTITUTE(A1,";"," "))," ","</B><B>")&"</B></A>","//B")))
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-23-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    16

    Re: To fix a formula that is giving the wrong data

    Quote Originally Posted by Glenn Kennedy View Post
    Duhh. Scrap that, use this..

    =TEXTJOIN("; ",TRUE,SORT(FILTERXML("<A><B>"&SUBSTITUTE(TRIM(SUBSTITUTE(A1,";"," "))," ","</B><B>")&"</B></A>","//B")))
    Hello Glenn,

    Thank you for this here. With the TRIM the semicolon is removed and with the SUBSTITUTE the semicolon and space are is that correct?

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: To fix a formula that is giving the wrong data

    No. Substitute removes the; and trim replaces double spaces in the string with a single space and removes single spaces at the start and end.

  8. #8
    Registered User
    Join Date
    06-23-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    16

    Re: To fix a formula that is giving the wrong data

    Quote Originally Posted by Glenn Kennedy View Post
    No. Substitute removes the; and trim replaces double spaces in the string with a single space and removes single spaces at the start and end.
    Ok, Thank you once again for the help and also for going into detail about it.

    This is truly a big help

+ 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] if formula is giving us wrong result
    By Ajay45822 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-12-2021, 12:55 PM
  2. Replies: 3
    Last Post: 07-04-2019, 02:56 PM
  3. Data Analysis giving wrong results
    By Pete291 in forum Excel General
    Replies: 1
    Last Post: 04-25-2018, 02:26 PM
  4. [SOLVED] Average formula giving wrong results
    By gko_87 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-07-2017, 10:15 AM
  5. [SOLVED] VLOOKUP giving wrong data
    By Zodeeak in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-24-2015, 10:39 AM
  6. Quotation marks in formula giving wrong output
    By pcfreakshow in forum Excel General
    Replies: 1
    Last Post: 10-11-2012, 03:00 PM
  7. formula giving wrong result sometimes?
    By lnjr in forum Excel General
    Replies: 2
    Last Post: 08-13-2010, 09:20 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