Search code examples
excelvbaexcel-formulaexcel-2010worksheet-function

Create unique sequence for row


I have a few thousand rows of data and need to create the unique sequences for each. Here is an example (each value is in its own cell):

Text1| Text2| Text2| Text2| Text3| Text3| Text1|

I need to create the unique sequence to look sometime like this

Text1| Text2| Text3| Text1|    or
Text1,Text2,Text3,Text1|

Any ideas?


Solution

  • If the first Text1 is in A1, then:

    =A1&","&IF(A1<>B1,B1&",","")&IF(B1<>C1,C1&",","")&IF(C1<>D1,D1&",","")&IF(D1<>E1,E1&",","")&IF(E1<>F1,F1&",","")&IF(F1<>G1,G1,"")  
    

    might be worth a try.