+ Reply to Thread
Results 1 to 27 of 27

Reversing formula breaks if input too long

  1. #1
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Reversing formula breaks if input too long

    =TEXTJOIN(",",,TRIM(MID(SUBSTITUTE(C2,",",REPT(" ",99)),((LEN(C2)-LEN(SUBSTITUTE(C2,",",""))+1)-ROW($XFD$1:INDEX(XFD:XFD,LEN(C2)-LEN(SUBSTITUTE(C2,",",""))+1)))*99+1,99)))

    I'm using it to take a series of words (example: Apple, Banana, Orange, Lime) and getting it to display them in reverse order, (example: Lime, Orange, Banana, Apple) This formula is also working up to a certain point, then breaking if the input is too long. I posted a similar thread today and someone was able to update it to a formula that better suits 365. I would need to reverse the order of up to 120 words at a time.

    I attached an example. To see how it breaks, just copy and paste the info in A2 to extend the input, and the columns down the line will stop working correctly. Thanks for any help!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Reversing formula breaks if input too long

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    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
    43,984

    Re: Reversing formula breaks if input too long

    I tidies up the first two formulae and then used this:

    =IFERROR(MID(TRIM(SUBSTITUTE($C$2,","," ")),(SUMPRODUCT(LEN($C$2:C2)*1)-LEN($C$2)+1),FIND(" ",TRIM(SUBSTITUTE($C$2,","," "))&" ",SUMPRODUCT(LEN($C$2:C2)*1)-LEN($C$2)+2)-(SUMPRODUCT(LEN($C$2:C2)*1)-LEN($C$2)+1)),"")

    copied across (to ZZZ in the file)

    It's working to 292 columns and will work for more.
    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

  4. #4
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Hey Glenn, thanks for the help. Unfortunately I need those asterisks to stay with their substitutions. When I try to make that happen, it throws the reverse sequence output off. Any help?

  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
    43,984

    Re: Reversing formula breaks if input too long

    And the commas? Not needed??

  6. #6
    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
    43,984

    Re: Reversing formula breaks if input too long

    Try it now.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Sorry, that does not work. Do you see how the 'reverse sequence output' doesn't show what it's supposed to now? Somewhere down the line it's messing up.


    The first word in 'reverse sequence output' should be the last in 'sequence output', but it isn't.

  8. #8
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    If anyone could help with the formula under "Reversed sequence output" from Glenn's "reverse sequence output error (1).xlsx‎" file and get it to display everything properly (commas or no commas), it would be greatly appreciated. It's the last piece of the puzzle for me.

  9. #9
    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
    43,984

    Re: Reversing formula breaks if input too long

    Now, now. We don't expect posts to be bumped until at least 24 hr. There were a number of issues. Eventually, I chucked everything out and went back to basics. For fun, I was trying to teach myself FILTERXML yesterday. I have been in total awe of those who can use it proficiently. Your problem was tailor made for FILTERXML. So having failed at my first attempt and having failed to figure out what was wrong...

    Try this, in C2, copied across (it's to ZZ) in the attached file:

    =IFERROR(LET(S,"<A><B>"&SUBSTITUTE($B$2," ","</B><B>")&"</B></A>",L,LEN($B$2)-LEN(SUBSTITUTE($B$2," ",""))+1,FILTERXML(S,"//B["&L-(COLUMNS($C2:C2)-1)&"]")),"")

    I think it's OK... but check it over... nucleotide sequences always leave me with spots in front of my eyes!!
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Reversing formula breaks if input too long

    Here is UDF Code
    Please Login or Register  to view this content.
    in D2
    =ReverseWords(B2)
    How to Use UDF code:
    In Tthe developer tab click--> Visual Basic
    VB window opens
    Insert--> Module
    Paste the code.
    Close the window.
    Now UDF is available in Function List
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  11. #11
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Sorry for the bump earlier.

    Glenn when I open that file and try to edit the sequence at all, everything in C2 and beyond just disappears. Doesn't come back even if I ctrl+z what I just did.

  12. #12
    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
    43,984

    Re: Reversing formula breaks if input too long

    What exactly did you edit? I just afdded a few random nucleotides onto the end of A2 and it worked perfectly...

    Please confirm that you ARE using Excel 365. When you launch Excel does it say in the rectangular green screen, as it starts up?

  13. #13
    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
    43,984

    Re: Reversing formula breaks if input too long

    Here's a screenshot...
    Attached Images Attached Images

  14. #14
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Yep it says 365 ProPlus

    All I'm editing is anything in A2. For example I deleted the first "A" in the sequence and it disappears. I'll upload my file. When I reopen this file it still doesn't work either.

  15. #15
    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
    43,984

    Re: Reversing formula breaks if input too long

    Administrative Note:

    Welcome to the forum.

    It has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    Since you are new here, I have done if for you THIS time. Feel free to cross post. Just don't keep it a secret.

    https://www.mrexcel.com/board/thread...rmula.1157548/

    Expect your thread to be blocked, until YOU provide the link, if you fail to declare cross-posts again. A lot of people (me included) get irritated if we have spent a lot of time working on a problem that you have already found a nice solution for elsewhere.

  16. #16
    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
    43,984

    Re: Reversing formula breaks if input too long

    Quote Originally Posted by EKrotz View Post
    All I'm editing is anything in A2. For example I deleted the first "A" in the sequence and it disappears. I'll upload my file. When I reopen this file it still doesn't work either.
    Works fine over here!!

  17. #17
    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
    43,984

    Re: Reversing formula breaks if input too long

    Here it is.... first A deleted.
    Attached Images Attached Images

  18. #18
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Not sure what to do about this. It's the exact solution I need it just doesn't work for me. Anything I touch in A2 deletes the output for C2 onward. Is there something I need to have enabled for that function to work?

    Sorry about the impatience and other forum post. I'll be sure to fully read the rules next time.

  19. #19
    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
    43,984

    Re: Reversing formula breaks if input too long

    Just a possibility... does your version of Excel support LET?

    Type =LET( in a cell... does the function appear?

    And just check FILTERXML, too, though since it's been around for a few years, that's not likely to be the problem.

  20. #20
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    =LET does not work

    FILTERXML does work

  21. #21
    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
    43,984

    Re: Reversing formula breaks if input too long

    OK. Bl@@dy microsoft!!

    Here's a LET-free version. Check it and then I'll explain...

  22. #22
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    Hey, it works!

  23. #23
    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
    43,984

    Re: Reversing formula breaks if input too long

    OK.... I have had O365 for about a week, and I'm trying to use its new functionality. So, on this occasion, I have to curb my enthusiasm. Instead of LET, which allows me to "give a formula a short name" I used Named Ranges instead (CTRL-F3 to view/edit)... So, I defined S (for string...) to add the XML code to your space-separated string in B2; and L (for length) as the number of nodes in the XML string, diminishing by 1 per column as the formula is dragged to the right (is the opposite of increments, excrements?? It feels that way today!!).

    You ahev to be careful with setting up NRs. They have a tendence to wander.. to the last row or column, or insert multiple sets of " on a whim. So, when settinng them up I routinely check them TWICE, just to make sure that they have not wandered off to some far-flung part of your sheet.

    How do you intend to use this sheet? One sequence at a time in A1, or separate sequences in A1, A2, etc. I may need to tweak the NRs if the latter option is your answer.

  24. #24
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    I intend to use 2 up to 4 sequences at a time.

  25. #25
    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
    43,984

    Re: Reversing formula breaks if input too long

    OK. The NRs have been tweaked and they SEEM to be OK. See file. It'll be fine for any number of rows in column A
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    01-04-2021
    Location
    Iowa
    MS-Off Ver
    microsoft office 365 proplus
    Posts
    14

    Re: Reversing formula breaks if input too long

    This is problem solved. Thank you so much, you are legendary!

  27. #27
    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
    43,984

    Re: Reversing formula breaks if input too long

    You're welcome and thanks for the rep.

+ 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] Delimiting formula breaks if input too long
    By EKrotz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-04-2021, 12:42 PM
  2. [SOLVED] Find out if a value/input breaks a range
    By Martijn79 in forum Excel General
    Replies: 5
    Last Post: 04-09-2020, 07:29 AM
  3. [SOLVED] Long formula breaks when adding nested IF
    By mgumapas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-28-2020, 07:52 AM
  4. Data Validation Formula Too Long too Input
    By 333onlyhalfevil in forum Excel General
    Replies: 1
    Last Post: 09-15-2019, 09:25 PM
  5. fixing line breaks in long csv file so columns align
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2014, 03:06 PM
  6. Replies: 4
    Last Post: 02-06-2006, 05:00 AM
  7. [SOLVED] Wildcard MATCH() breaks on long (?) strings
    By [email protected] in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-05-2005, 10: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