+ Reply to Thread
Results 1 to 33 of 33

nested substitute giving me problems

  1. #1
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    nested substitute giving me problems

    So I put this formula in excel in e4 and I get a value of 1 for 1 in e3. I also get 2 for 2 but I get the correct results with 3 = 2 and 4 = 1.
    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(d3,"1","4"),"2","3"),"3","2"),"4","1")
    What am I doing wrong
    excel.jpg
    Last edited by Doc_62; 11-17-2022 at 06:59 AM.

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

    Re: nested substitute giving me problems

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(d3,"1","4"),"2","3"),"3","2"),"4","1")

    with 1 in D3, the nesting, step 1 returns a 4... the next 2 steps have no relevance and the last one converts the 4 back to 1!!

    I suspect what you actually want is:

    =LOOKUP(D3,{1,2,3,4},{4,3,2,1})
    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

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    First you substitute 1 by 4 and then the 4 by 1.
    That also happens with 2 and 3.

    Please try in E3
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    That works perfectly!
    TYVM
    Last edited by Doc_62; 11-17-2022 at 07:49 AM.

  5. #5
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Quote Originally Posted by Glenn Kennedy View Post
    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(d3,"1","4"),"2","3"),"3","2"),"4","1")

    with 1 in D3, the nesting, step 1 returns a 4... the next 2 steps have no relevance and the last one converts the 4 back to 1!!

    I suspect what you actually want is:

    =LOOKUP(D3,{1,2,3,4},{4,3,2,1})
    That works perfectly!
    TYVM

  6. #6
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Now, how do I delete a post?
    I replied without quoting the relevant post.

  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 2406
    Posts
    44,662

    Re: nested substitute giving me problems

    YOU can't delete, it... but you can EDIT it, by going to the relevant post and clicking edit post, in the grey bar at the foot of the post.

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    You are welcome, glad to have helped and thanks for the feedback.

  9. #9
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    ..........

  10. #10
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Ok, so how would I get that formula to do multiple numbers in a cell?

  11. #11
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    Please give a concrete example.

  12. #12
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    I would like it to convert multiple numbers in a cell.
    formula.jpg
    Last edited by Doc_62; 11-17-2022 at 09:30 PM.

  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 2406
    Posts
    44,662

    Re: nested substitute giving me problems

    That's a new requirement. Suddenly uncovered after 10 posts. With an old version of Excel (Excel 2010) your options are limited.

    Please Login or Register  to view this content.
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    Then:

    =concatall(LOOKUP(--MID(D3,ROW(INDIRECT("1:"&LEN(D3))),1),{1,2,3,4},{4,3,2,1}))

    An array formula. These are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see the curly brackets { } appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    Another option:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  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 2406
    Posts
    44,662

    Re: nested substitute giving me problems

    Assuming that the sample is representative of the real data!!! It seems a bit unlikely. However, the explanation of the requirement was more than a little vague.

  16. #16
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: nested substitute giving me problems

    I'm agree with HansDouwe, the op want to convert number to the opposit of 5
    (1 > 4, 2 > 3, 3 > 2, 4 > 1) so use 5 (equal to number of digits) and subtract should be ok.

    Regards.

  17. #17
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Sorry m8, I thought it would be pretty simple formula. As a noob to excel, I thought I was pretty close and I would just need to be pointed in the right direction and I'd be able to work it out myself.
    Its a horse racing program. I had some neurals for different traits that were a bit erratic so I managed to write formulas to smooth out the data. It was my first ever attempt at doing something in excel and I ended up with some pretty funky formulas by myself just googling what I needed.
    I wanted to add points for 1st, 2nd 3rd and 4th thinking it cant be that hard. Its been tougher than some of the other stuff I have done that was rather complicated. You would think changing the value of 1 2 3 4 wouldnt be that hard. How wrong I was.
    I'll give what you've posted a bash. TY

  18. #18
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Quote Originally Posted by HansDouwe View Post
    Another option:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Uuuummm....
    How did that work????
    You lot are geniuses.
    I must say I enjoy this stuff. I think I missed my calling. Too old now though. Just turned 60.
    Last edited by Doc_62; 11-18-2022 at 05:33 AM.

  19. #19
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Ok, maths on the 5 thingy makes perfect sense now I think about it.

  20. #20
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    If you want add points for 1st, 2nd 3rd and 4th, I don't expect 4212 in 1 cell.
    I expect the position numbers in different cells.
    In that case are the formula in Post #2 and Post #3 are suitable. Formula in Post #2 and the first formula of Post #3 are most flexible, because you can easy change the number of points to be awarded.
    Last edited by HansDouwe; 11-18-2022 at 05:42 AM.

  21. #21
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Quote Originally Posted by HansDouwe View Post
    If you want add points for 1st, 2nd 3rd and 4th, I don't expect 4212 in 1 cell.
    I expect the position numbers in different cells.
    In that case are the formula in Post #2 and Post #3 are suitable. Formula in Post #2 and the first formula of Post #3 are most flexible, because you can easy change the number of points to be awarded.
    It wont do it without splitting the numbers into seperate cells. I was working on that with =MID($e3,COLUMN()-(COLUMN($f3)- 1),1)

  22. #22
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Ok, here's where I'm up to.
    Remove x (horse had a spell)
    Attachment 805556
    Get just the last 5 runs.
    Attachment 805557
    Remove numbers not 1 - 4
    Attachment 805558
    I guess I could do a remove 5 on the next column created with the 5555 formula. The f is something that only pops up rarely. I could probably ad remove f to the the remove x formula. I could probably work around the no value's easily enough.

  23. #23
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    I haven't looked in to it yet but addition of
    numbers in a cell is simple enough? lol
    Last edited by Doc_62; 11-18-2022 at 06:59 AM.

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

    Re: nested substitute giving me problems

    PNon-editable pictures are not helpful. Upload a small excel sheet (10-20 rows max) with a fully representative sample of what you have and what you want.

  25. #25
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Quote Originally Posted by Glenn Kennedy View Post
    PNon-editable pictures are not helpful. Upload a small excel sheet (10-20 rows max) with a fully representative sample of what you have and what you want.
    Its late here(AU)
    I'll get something for you tomorrow.

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

    Re: nested substitute giving me problems

    No problem! Whenever...

  27. #27
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Ok, here's where I'm at.
    Subtracted the x's out of last 10 runs.
    Got the last 5 runs.
    Cut out anything that wasn't 1 to 4.
    Now I want to give these numbers the new value.
    Attached Files Attached Files

  28. #28
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    I think i got it sorted.
    I can delete #value easily enough from there.
    Attached Files Attached Files

  29. #29
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    I probably need to multiply that number by say 1.5 to give it a bit more weight.
    Thats Ascot(Western Australia) race 6. Along with my other Neurals, the tip is Minsk Moment paying $9.
    Attachment 805683
    Last edited by Doc_62; 11-19-2022 at 12:21 AM.

  30. #30
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    A big thank you to all who helped.
    I have it all loaded in a macro and it just takes a couple of minutes to do a full meeting.

  31. #31
    Registered User
    Join Date
    11-01-2022
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    41

    Re: nested substitute giving me problems

    Minsk Moment goes BAAAAANG!!!!

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

    Re: nested substitute giving me problems

    Glad you got sorted. For next time, bear in mind:

    1. A SMALL sample sheet (at Post 1) helps.

    2. It should be fully representative.

    3. It should have an explanation and some expected results.

    Then it might all be a lot quicker...

  33. #33
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: nested substitute giving me problems

    Thanks for the feedback and sharing your end solution, Glad to have helped.
    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] Nested Substitute for First Character?
    By WaveWalker116 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-13-2020, 09:52 AM
  2. [SOLVED] SUMPRODUCT syntax problems (to substitute SUMIFS)
    By Phillycheese5 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-12-2019, 01:27 PM
  3. Nested Formula Help - LEFT and Substitute
    By keith.will in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2015, 01:55 PM
  4. [SOLVED] Complex ??Need to adjust formula giving unexpected results with trim & substitute
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-15-2015, 03:48 AM
  5. SUBSTITUTE formula giving unexpected result
    By gkeller81 in forum Excel General
    Replies: 15
    Last Post: 06-04-2012, 01:16 PM
  6. SUBSTITUTE nested within IF
    By malibu06 in forum Excel General
    Replies: 5
    Last Post: 01-18-2011, 11:57 PM
  7. Eliminate the need for Nested Substitute
    By ElmerS in forum Excel General
    Replies: 3
    Last Post: 04-09-2010, 04:41 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