+ Reply to Thread
Results 1 to 6 of 6

Substitute a X character more than 1 instance and from different directions

  1. #1
    Registered User
    Join Date
    04-05-2014
    Location
    São Paulo, Brasil
    MS-Off Ver
    Excel 2007
    Posts
    12

    Substitute a X character more than 1 instance and from different directions

    I want to substitute the " " instances from the lines below with "|".
    The challenge here is to substitute only the first instance (from Left to Right) and then substitute the second and the fourth instances (from Right to Left).

    1 Kick-off Meeting Tue 04/01/14 Tue 04/01/14
    2 Site survey and assessment Thu 04/06/14 Fri 04/07/14
    16 Drawing Analysis Mon 04/21/14 Fri 04/25/14

    The final result should be like this:

    1|Kick-off Meeting|Tue 04/01/14|Tue 04/01/14
    2|Site survey and assessment|Thu 04/06/14|Fri 04/07/14
    16|Drawing Analysis|Mon 04/21/14|Fri 04/25/14

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Substitute a X character more than 1 instance and from different directions

    Try this one

    =SUBSTITUTE(LEFT(A1,FIND(" ",A1))&"|"," ","")&TRIM(MID(A1,FIND(" ",A1)+1,FIND("/",A1)-3-FIND(" ",A1)-5))&"|"&SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)*4))," ","|",2)

    A
    B
    1
    1 Kick-off Meeting Tue 04/01/14 Tue 04/01/14 1|Kick-off Meeting|Tue 04/01/14|Tue 04/01/14
    2
    2 Site survey and assessment Thu 04/06/14 Fri 04/07/14 2|Site survey and assessment|Thu 04/06/14|Fri 04/07/14
    3
    16 Drawing Analysis Mon 04/21/14 Fri 04/25/14 16|Drawing Analysis|Mon 04/21/14|Fri 04/25/14
    Last edited by AlKey; 04-12-2014 at 12:40 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Registered User
    Join Date
    04-05-2014
    Location
    São Paulo, Brasil
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Substitute a X character more than 1 instance and from different directions

    Hi Alkey,

    There is one case in particular which of the solution did not go well... I got "#VALUE!" when the numbers end with "0"

    10 Define specs Mon 16/06/14 Mon 16/06/14
    20 Set parameters Mon 16/06/14 Mon 16/06/14
    30 Place PO Mon 16/06/14 Mon 16/06/14
    40 Hire Consultant and Providers Mon 16/06/14 Mon 16/06/14

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Substitute a X character more than 1 instance and from different directions

    Sorry, I did adjust formula on the original post. It should work fine now.

  5. #5
    Forum Contributor
    Join Date
    12-22-2010
    Location
    Rio, Brazil
    MS-Off Ver
    Excel 2010, 2016
    Posts
    209

    Re: Substitute a X character more than 1 instance and from different directions

    Hi

    To make things easier, i suggest a Helper column (see column D in the below example)


    A
    B
    C
    D
    1
    Text
    New Text
    Spaces
    2
    1 Kick-off Meeting Tue 04/01/14 Tue 04/01/14
    1|Kick-off Meeting|Tue 04/01/14|Tue 04/01/14
    6
    3
    2 Site survey and assessment Thu 04/06/14 Fri 04/07/14
    2|Site survey and assessment|Thu 04/06/14|Fri 04/07/14
    8
    4
    16 Drawing Analysis Mon 04/21/14 Fri 04/25/14
    16|Drawing Analysis|Mon 04/21/14|Fri 04/25/14
    6
    5
    10 Define specs Mon 16/06/14 Mon 16/06/14
    10|Define specs|Mon 16/06/14|Mon 16/06/14
    6
    6
    20 Set parameters Mon 16/06/14 Mon 16/06/14
    20|Set parameters|Mon 16/06/14|Mon 16/06/14
    6
    7
    30 Place PO Mon 16/06/14 Mon 16/06/14
    30|Place PO|Mon 16/06/14|Mon 16/06/14
    6
    8
    40 Hire Consultant and Providers Mon 16/06/14 Mon 16/06/14
    40|Hire Consultant and Providers|Mon 16/06/14|Mon 16/06/14
    8


    Formula in D2 copied down
    =LEN(A2)-LEN(SUBSTITUTE(A2," ",""))

    Formula in B2 copied down
    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2," ","|",1)," ","|",D2-2)," ","|",D2-4)

    Hope this helps
    (Espero que ajude )

    M.
    Marcelo Branco

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Substitute a X character more than 1 instance and from different directions

    Thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).

+ 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: 9
    Last Post: 08-20-2013, 10:01 AM
  2. nth instance of a character in a string
    By AndrewMac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2013, 11:20 AM
  3. Multiple Character Substitute Formula
    By IanE78 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-01-2012, 11:02 AM
  4. Replies: 2
    Last Post: 04-03-2011, 07:16 PM
  5. [SOLVED] Find nth instance of a character in a string
    By Francis Hayes (The Excel Addic in forum Excel General
    Replies: 7
    Last Post: 01-21-2005, 12:06 PM

Tags for this Thread

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