Excel formula problem

Hello and thank you in advance for your help,

I want to find a formula to concatenate data, but I am facing the following problem with my file

I found the following formula

if (A1="";concat (b1;" ";b2))

if (a1="";a2="";concat b1;" "; b2;" ";b3)  

etc etc I can have labels up to 7 lines

the formula works but I can't find the solution to nest 

example from my file

      column a (code)                               column b (a part of the label)   

1            000001                                        sofa

2                                                                   gray with armrest

3                                                                   and wooden foot

4           000002                                           click clack

4            000003                                          armchairs

6                                                                     sets of 2 green

7           000004                                             carpet

8                                                                     multicolored

9         

10

9 answers

  1. Hello,

    Here is what we can achieve with Power Query (natively integrated into Excel since 2016)

    Example file under this link


    1
    1. Hello cousinhub29,

      Great solution, well done.

      0
  2. Hello everyone,

    Solution with Excel 365, the data being in column A and B:

     =GROUPBY(SCAN("",A1:A8,LAMBDA(x,y;IF(y<>"",y,x)));B1:B8&" ";CONCAT;;0)

    Daniel


    1
    1. Hello,

      In which column is the formula ... and the expected result?


      Regards.
      The Penguin

      0
      1. hello,

        first of all, thank you for looking into my issue

        column C

        0
        1. a second important indication, my file has more than 10,000 rows, I would like to be able to drag the formula down the entire column knowing that the formula must be able to take the right number of rows to concatenate, knowing that I may need to concatenate 2 rows for the next code, 7 rows for the next one, and 4 rows for the third

          I hope I have been clear in my example

          Thank you in advance

          0
          1. "I hope I was clear in my example"

            cousinhub was just as clear!

            Especially since you didn't specify your version of Excel either!


            Best regards

            0
        2. Hello,

          If it's a one-time operation, I would copy your data into Word and use Find and Replace "^p^t" with "space" to concatenate everything, then just switch it back to Excel.

          0
          1. Contributor

            Hello Maestro réj

            One idea with A1:A10 as the selected cells containing an x in B1:B10 for the labels.

            In C1 this formula: =IF($A$1="x",$B$1,"")&IF($A$2="x",$B$2,"")&IF($A$3="x",$B$3,"")&IF($A$4="x",$B$4,"")&IF($A$5="x",$B$5,"")&IF($A$6="x",$B$6,"")&IF($A$7="x",$B$7,"")&IF($A$8="x",$B$8,"")

            It is by forging that one becomes a blacksmith. It is at the foot of the wall that one sees the mason. One always learns from one's mistakes.

            0
            1. Maestro Réj specified that he had 10,000 lines. Your formula uses absolute addresses, so it can't be copied, and that would mean putting "x" in the N thousands of lines to be gathered… without making a mistake…

              0