Forum Discussion

achow1565's avatar
achow1565
Copper Contributor
Jul 06, 2023

Creating table from email body and repeating columns

I want to convert an email body from a website form to an easy to read table so we can enter it into our Access database. This is what would come in after copy/pasting the email body into Excel.

Data from email body

I found a link online that would transpose every n rows into columns, so I can get the data to look like this.

After transposing with VBA code

The thing is that my last 4 columns (quantity, customer PN, MN part #, MN serial #s) will repeat depending on how many part numbers there are. I want my final table to look like below. I found this link that is similar to what my goal is, but I couldn't follow along and don't know if it can account for the varying number of repeating last 4 columns. Can somebody help me out with the code?

What I want my final results to be

  • achow1565 

    This will do it. I hope you have 365!

    =LET(
        header, INDEX(list, SEQUENCE(, 13, 1, 2)),
        organized, DROP(
            REDUCE(
                "",
                header,
                LAMBDA(a, v,
                    LET(
                        r, FILTER(ROW(list), list = v) + 1,
                        IFERROR(HSTACK(a, INDEX(list, r)), "")
                    )
                )
            ),
            ,
            1
        ),
        VSTACK(header, organized)
    )

     I created a function to do this. You'll find it all in the workbook attached. 

    • achow1565's avatar
      achow1565
      Copper Contributor

      Patrick2788 that is much simpler!

       

      The second part I'm trying to do is get A27:A34 (the even cells) under the columns created for A19:26. The headers are the same so I don't want to be creating more columns, rather more rows. Do you know of a solution for that?

Resources