Home > front end >  Add comma at the end of cell in excel
Add comma at the end of cell in excel

Time:12-14

I am having a excel sheet with data like below(image attached) where I am adding comma at the end of cell using concatenate formula. Formula works fine for cell with single values like Train--> Train, but when multiple entries are present in cell, concatenate formula is not working like car road bus truck --> carroadbustruck, How can I get cell in this format car,road,bus,truck,

enter image description here

CodePudding user response:

While SUBSTITUTE() will work as @Tim suggested. You can also use TEXTSPLIT() with CONCAT().

=IFERROR(CONCAT(TEXTSPLIT(B1,CHAR(10))&","),"")

enter image description here

CodePudding user response:

We can use the SUBSTITUTE() function here along with concatenation:

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

This assumes that your intended logic is to replace newlines with comma, and also tag on an extra trailing comma at the end.

  • Related