Formula to Concat cells in Row, Skip blanks and add HTML code (text)

undrgnd

New Member
Joined
Apr 23, 2016
Messages
10
Hey all,

I have been trying to create a formula to concat 7 cells in a row, skip blanks, and add some HTML tags to it. I know the formaula wont work below but I have put it back to basic and need help to get it to the next step. Details below:

=CONCAT("[ul][li]",IF(A2="","",A2),"[/li][li]",IF(B2="","",B2),"[/li][li]",IF(C2="","",C2),"[/li][li]",IF(D2="","",D2),"[/li][li]",IF(E2="","",E2),"[/li][li]",IF(F2="","",F2),"[/li][li]",IF(G2="","",G2),"[/li][/ul]")

Feature1Feature2Feature3Feature4Feature5Feature6Feature7Result
RoundSquareFlatEdgeGreatLittleSolid

  • [ul][li]Round[/li][li]Square[/li][li]Flat[/li][li]Edge[/li][li]Great[/li][li]Little[/li][li]Solid[/li][/ul]

    <tbody>
    </tbody>

<tbody>
</tbody>
RoundSquareFlatEdgeGreat


<tbody>
</tbody>
[ul][li]Round[/li][li]Square[/li][li]Flat[/li][li]Edge[/li][li]Great[/li][li][/li][li][/li][/ul]

<tbody>
</tbody>

<tbody>
</tbody>

Row 1 is correct as there are 7 features. Row 2 is wrong and it should finish after feature 5 and should look like this:

  • [ul][li]Round[/li][li]Square[/li][li]Flat[/li][li]Edge[/li][li]Great[/li][/ul]

    <tbody>
    </tbody>


So at the start of every row is [ul][li] then between each feature is [/i][li] and then at the lend of the last feature it is [/li][/ul]

<tbody>
</tbody>

Also, is there any recommendation on sites etc to learn the next level of excel including VBA's etc.

Many thanks in advance.

Chris

EDIT: i had to replace <> with [] due to formatting issues.
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try:
Code:
=CONCATENATE("[ul]", IF(A2="","","[li]"&A2&"[/li]"), IF(B2="","","[li]"&B2&"[/li]"), IF(C2="","","[li]"&C2&"[/li]"), IF(D2="","","[li]"&D2&"[/li]"), IF(E2="","","[li]"&E2&"[/li]"), IF(F2="", "","[li]"&F2&"[/li]"), IF(G2="","","[li]"&G2&"[/li]"),"[/ul]")
 
Upvote 0
Man that works a treat.. thank you so much.

I was heading down this path =CONCAT("[ul][li]",SUBSTITUTE(TRIM(TEXTJOIN(" ",TRUE,A4:G4))," ","[/i][li]"),"[li][ul]") but realised that if i had two words as a feature ie super solid, if would ad the [/i][li] after each space.
 
Upvote 0
Don't you just need this?


Book1
ABCDEFGH
1Feature1Feature2Feature3Feature4Feature5Feature6Feature7Result
2RoundSquareFlatEdgeGreatLittleSolid[ul][li]Round[/li][li]Square[/li][li]Flat[/li][li]Edge[/li][li]Great[/li][li]Little[/li][li]Solid[/li][/ul]
3RoundSquareFlatEdgeGreat[ul][li]Round[/li][li]Square[/li][li]Flat[/li][li]Edge[/li][li]Great[/li][/ul]
4Thishas multi word cellsinit[ul][li]This [/li][li]has multi word cells[/li][li]in[/li][li]it[/li][/ul]
Concat undrgnd
Cell Formulas
RangeFormula
H2="[ul][li]"&TEXTJOIN("[/li][li]",1,A2:G2)&"[/li][/ul]"
 
Last edited:
Upvote 0
Thank you Peter, this works very well too and less complicated. I only learned Textjoin today and think its going to be part of the repertoire.
 
Upvote 0
Although, it is not exactly what you need, but can you use this. In order for this to work, you would need to have your source data vertically. In my example i selected the items in row 7 plus two empty rows. So my formula concatenates and transposes your data. I also included a * after each word (included the two empty cells. The formula is =concatenate(transpose(range&"*")). You must first highlight the transpose(.....) part of your formula with your mouse. Hit F9. Remove the { and }. Hit enter.


Round
Square
Flat
Edge
Great
Little
Solid
Round*Square*Flat*Edge*Great*Little*Solid***

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Although, it is not exactly what you need, but can you use this.
Mike, I'm wondering why the OP would consider using this when, as you have stated, it isn't exactly what was needed and it's quite a complicated process compared to the straight-forward formula that already does exactly what is needed?

I'm also wondering why for it to work you have to put the data vertically? If you leave it horizontal and leave the transpose out of your formula, exactly the same result can be achieved.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,562
Members
449,171
Latest member
jominadeo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top