+ Reply to Thread
Results 1 to 19 of 19

Add a string between beginning and and of a chain per corresponding code

  1. #1
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Add a string between beginning and and of a chain per corresponding code

    Find strings "BEGINNING" and "END" and add between them a string "BETWEEN" per every code.
    Notice that one code can have more than one chain (chain starts with string "BEGINNING", ends with string "END")
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Add a string between beginning and and of a chain per corresponding code

    Put this formula in D1:

    =A1

    and this one in D2:

    =IF(OR(ISNUMBER(SEARCH("beginning",A2)),ISNUMBER(SEARCH("end",A2))),A2,IF(COUNTIF(A$1:A1,"*beginning")=COUNTIF(A$1:A1,"*end"),A2,A2&" between"))

    Copy the formula from D2 down as far as you need to.

    Hope this helps.

    Pete

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Add a string between beginning and and of a chain per corresponding code

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    Thank you AlphaFrog!!!
    Can I just put E1 (and E where column A is in code) if I want this to work for column E?

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Add a string between beginning and and of a chain per corresponding code

    You're welcome and yes.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a string between beginning and and of a chain per corresponding code

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    Works too!
    Thank you so much

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a string between beginning and and of a chain per corresponding code

    You're welcome. AlphaFrog's better though.

  9. #9
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    I tested program and noticed that it adds BETWEEN even for codes that don't have BEGINNING and END - if you rename cell A3 to CODE3 you will see it adds BETWEEN even thou CODE3 doesn't have BEGINNING and END

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Add a string between beginning and and of a chain per corresponding code

    Quote Originally Posted by percuk17 View Post
    I tested program and noticed that it adds BETWEEN even for codes that don't have BEGINNING and END - if you rename cell A3 to CODE3 you will see it adds BETWEEN even thou CODE3 doesn't have BEGINNING and END
    No need to PM me. I get notified, like you, when there is a reply to a thread I'm subscribed to.

    Try this...

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a string between beginning and and of a chain per corresponding code

    Not sure what you want to happen when that occurs, does this help?

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    It worked again for the sample I submitted and I thank you for that.
    Obviously I didn't express my self well enough so that your code can work for every possible case. The problem is when BEGINNING is also interposal.
    My English is limited so I put down the case when code can not do the task.
    CODE1
    CODE1 BEGINNING
    CODE2
    CODE2 BEGINNING
    CODE1
    CODE1 END
    CODE1
    CODE1
    CODE1 BEGINNING
    CODE1
    CODE1
    CODE1
    CODE1 END
    CODE1
    CODE1
    CODE2
    CODE2
    CODE2
    CODE2
    CODE2
    CODE2
    CODE2
    CODE2 END
    CODE2
    CODE1
    CODE1 BEGINNING
    CODE1
    CODE1
    CODE1
    CODE1 END
    CODE1
    CODE1

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a string between beginning and and of a chain per corresponding code

    ?? Maybe:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    Hey John,
    thanks again for working on this.
    I tried but it did only for CODE1 but not for CODE2 that has BEGINNING at cell A4 and END at cell A23

  15. #15
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    In addition codes (CODE1, CODE2...) could be something totally different, like EA, ANYTHING...

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add a string between beginning and and of a chain per corresponding code

    I think I misinterpreted what you are looking for? Can you provide the expected results for Post #12.

  17. #17
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    This is the resulting column

    CODE1
    CODE1 BEGINNING
    CODE2
    CODE2 BEGINNING
    CODE1 BETWEEN
    CODE1 END
    CODE1
    CODE1
    CODE1 BEGINNING
    CODE1 BETWEEN
    CODE1 BETWEEN
    CODE1 BETWEEN
    CODE1 END
    CODE1
    CODE1
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 BETWEEN
    CODE2 END
    CODE2
    CODE1
    CODE1 BEGINNING
    CODE1 BETWEEN
    CODE1 BETWEEN
    CODE1 BETWEEN
    CODE1 END
    CODE1
    CODE1

  18. #18
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Add a string between beginning and and of a chain per corresponding code

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-16-2017 at 12:18 PM.

  19. #19
    Registered User
    Join Date
    02-09-2017
    Location
    Atlanta, GA
    MS-Off Ver
    2010
    Posts
    11

    Re: Add a string between beginning and and of a chain per corresponding code

    Bingo! Totally works!
    Sorry for being confusing and thank you a million

+ 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: 1
    Last Post: 04-12-2014, 04:03 PM
  2. Need Help generating a and copying a chain of code.
    By borderpc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-12-2013, 01:36 PM
  3. Move Text From End Of String To Beginning
    By Tellm in forum Excel General
    Replies: 4
    Last Post: 06-28-2013, 06:09 AM
  4. Replies: 5
    Last Post: 09-08-2010, 03:45 PM
  5. Replies: 3
    Last Post: 09-08-2010, 09:49 AM
  6. Add a string at the beginning and end
    By patyandra in forum Excel General
    Replies: 2
    Last Post: 12-05-2009, 07:05 PM
  7. Is there away to add a zero to the beginning of number string?
    By Anthony in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-15-2006, 06:55 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