+ Reply to Thread
Results 1 to 7 of 7

Formula or Function to Reorder Values or Text Strings

  1. #1
    Forum Contributor
    Join Date
    02-20-2011
    Location
    Candada
    MS-Off Ver
    Microsoft Office 365
    Posts
    174

    Formula or Function to Reorder Values or Text Strings

    Greetings everyone,
    Thank for taking your time to view this thread. I am looking for a formula or function to reorder the text string "TRUE" and "FALSE", so they all are in the same order
    The final result that I'm looking for is as follow:
    % TRUE, % FALSE
    % TRUE, % FALSE
    % TRUE, % FALSE
    Please take a look at the attached document for sample.
    Again thank you for much for your time and dedication to this wonderful forum.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Formula or Function to Reorder Values or Text Strings

    Give this formula a try (put it in cell B2 and copy down to the end of your data)...
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 02-06-2020 at 12:10 AM.

  3. #3
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Formula or Function to Reorder Values or Text Strings

    Given your data in col A beginning in A2, try

    B2: =IF(COUNTIF(A2,"*,*"),IF(COUNTIF(A2,"* TRUE,*"),A2,REPLACE(A2,1,FIND(",",A2)+2,"")&", "&LEFT(A2,FIND(",",A2)-1)),IF(COUNTIF(A2,"* TRUE*"),"100.00% TRUE, 0.00% FALSE","0.00% TRUE, 100.00% FALSE"))

    This always produces both TRUE and FALSE parts, so 100.00% TRUE, 0.00% FALSE and 0.00% TRUE, 100.00% FALSE.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Formula or Function to Reorder Values or Text Strings

    Quote Originally Posted by Rick Rothstein View Post
    Give this formula a try (put it in cell B2 and copy down to the end of your data)...
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Actually, this shorter formula works the same as the above formula...
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Formula or Function to Reorder Values or Text Strings

    Quote Originally Posted by hrlngrv View Post
    This always produces both TRUE and FALSE parts, so 100.00% TRUE, 0.00% FALSE and 0.00% TRUE, 100.00% FALSE.
    If you are correct about the OP wanting TRUE/FALSE percentages even for 100% conditions, then here is a slightly more compact formula that produces the same output that your formula does...
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Formula or Function to Reorder Values or Text Strings

    Going for brevity? Note that all original entries have 2 spaces between % and T or F. If we should preserve that formatting too,

    =IF(LEFT(A3,3)="100",REPLACE("0.00% TRUE, 0.00% FALSE",1+(MID(A3,7,1)="F")*14,0,10),MID(A3&", "&A3,1+COUNTIF(A3,"*F*,*")*(FIND(",",A3)+2),LEN(A3)))

    is just a bit shorter. Then again, Excel stinks at text processing. Better to use Google Sheets, in which this could be done using

    =if(left(A3,3)="100",replace("0.00% TRUE, 0.00% FALSE",1+countif(A3,"*F*")*14,0,10),regexreplace(A3,"(.+F.+), *(.+)","$2, $1"))

    Someday Excel may support regular expressions.

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Formula or Function to Reorder Values or Text Strings

    Quote Originally Posted by hrlngrv View Post
    Note that all original entries have 2 spaces between % and T or F.
    I completely missed that!



    Quote Originally Posted by hrlngrv View Post
    Someday Excel may support regular expressions.
    Yes, that would be nice.

+ 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. Replies: 4
    Last Post: 10-12-2015, 01:44 PM
  2. Sum values in range of text strings based on other values
    By afgoody in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-07-2013, 04:15 PM
  3. [SOLVED] Time values from extracted text strings
    By Steve Roth in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-08-2012, 01:39 PM
  4. Concatenate function to join some text strings
    By FRJ1949(Frank) in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2010, 03:30 PM
  5. function that accounts for two different text strings
    By abrunstad in forum Excel General
    Replies: 3
    Last Post: 03-26-2009, 09:59 AM
  6. Summing values related to text strings
    By LACA in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2008, 03:58 PM
  7. [SOLVED] Custom Function If..Else and reading text strings
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-11-2005, 02:06 PM

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