根据条件将行转换为列所需的公式/macros

所以这里是我的困境,我把一个csv文件从一个电子商店转换到另一个,我需要重新安排数据。 移调将工作,但是我需要信息在指定的条件改变之后破解到新的行。

产品ID图像path等级
99999999 /image1.jpg 1
99999999 /image2.jpg 2
99999999 /image3.jpg 3
88888888 /image4.jpg 1

我需要输出如:

产品id imagepath imagepath2 imagepath3
99999999 /image1.jpg /image2.jpg /image3.jpg
88888888 /image4.jpg

所以基本上每当产品id变化时,我都需要将信息打破。 电子表格大概有1200行左右。 有些产品有7个图像,有些有一个。 我确定需要一个FOR LOOP,或者某种程度上的,但是我自己并没有那么好的macros来生成它,我似乎无法在这里find一个具体的例子。帮助!

你还试过了什么? 要求为你做? 你能至less提供一个代码或你所取得的进展吗?

<Maybe create a new table for your output> Set ProductValues = ActiveDocument.Fields("product id").GetPossibleValues For i = 0 To ProductValues.Count - 1 ActiveDocument.Fields("product id").Select ProductValues.Item(i).Text Set imagepath= ActiveDocument.Fields("imagepath").GetPossibleValues For j = 0 To imagepath.Count - 1 ActiveDocument.Fields("imagepath").Select imagepath.Item(i).Text Set rank= ActiveDocument.Fields("rank").GetPossibleValues For k = 0 To rank.Count - 1 ActiveDocument.Fields("rank").Select rank.Item(i).Text <if the current product_id exists on the export table> <copy current row information in new table> <if has already a picture, increase the table columns by 1 and add new picture url> <or if rank give the amount of picture, you can loop through all rank position at beginning in order to find the maximum rank and intialize your table with [][your rank]> <For export table you do mytable[0][0]=product id> <check if product id is different from mytable[i-position] and different from product id> <to do the picture part mytable[i-position][rank]=picture url> Next Next Next 

这应该让你有可能通过所有的单个元素一个接一个地完成剩下的工作,并创build新的表格。