Results 1 to 6 of 6

Thread: Excel adding Text before and after multiple strings within the same cell

  1. #1

    Excel adding Text before and after multiple strings within the same cell



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi All,


    I have a cell that has multiple lines within a single cell. What I need to do is add <p> before and after every string within the Cell after each string separated by a return.


    Original Cell Content


    <strong><img class="alignleft wp-image-7685" style="margin: 5px;" title="mother's day infertility support" src="/blog/uploads/2014/05/1525639_10151806402881017_1083857534_n.jpg" alt="" width="230" height="230" /></a>By Dacina McNabb</strong>

    "Ready or Not Here I come!"

    I've been hearing the taunting singsong voice of yet another holiday that I dread.


    New Cell Content



    <p><strong><img class="alignleft wp-image-7685" style="margin: 5px;" title="mother's day infertility support" src="/blog/uploads/2014/05/1525639_10151806402881017_1083857534_n.jpg" alt="" width="230" height="230" /></a>By Dacina McNabb</strong><p>

    <p>"Ready or Not Here I come!"<p>

    <p>I've been hearing the taunting singsong voice of yet another holiday that I dread.<p>

  2. #2
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,491
    Articles
    0
    Excel Version
    Excel 2016
    How are the substrings separated now? Do they have a Carriage Return (i.e. ALT+ENTER used)?


  3. #3
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,491
    Articles
    0
    Excel Version
    Excel 2016
    Maybe try:

    ="<p>"&SUBSTITUTE(A1,CHAR(10),"<p>"&CHAR(10)&"<p>")&"<p>"

    Where A1 contains the original


  4. #4
    yes the spaces are using ALT+ENTER. I tried the formula and it seems to work but I would like to not have the <p><p> in the spaces between strings. Is this possible? Thank for the help


    <p><strong><img class="alignleft wp-image-7685" style="margin: 5px;" title="mother's day infertility support" src="/blog/uploads/2014/05/1525639_10151806402881017_1083857534_n.jpg" alt="" width="230" height="230" /></a>By Dacina McNabb</strong><p>
    <p><p>
    <p>"Ready or Not Here I come!"<p>
    <p><p>
    <p>I've been hearing the taunting singsong voice of yet another holiday that I dread.<p>
    <p><p>

  5. #5
    Super Moderator NBVC's Avatar
    Join Date
    May 2011
    Location
    Mississauga, Canada
    Posts
    1,491
    Articles
    0
    Excel Version
    Excel 2016
    Try:

    =SUBSTITUTE("<p>"&SUBSTITUTE(A1,CHAR(10),"<p>"&CHAR(10)&"<p>")&"<p>","<p><p>","")


  6. #6
    Thank you This worked perfectly !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •