我需要重新格式化来自Shopify的大量图像导出。
它们已以以下格式导出:
A B
SKU | img source
1755 http://img1.jpg
http://img2.jpg
http://img3.jpg
1756 http://img1.jpg
http://img2.jpg
1757 http://img1.jpg
每个sku都有不同数量的图像。我需要所有的网址都在一行中以逗号分隔的列表中(与sku相同),然后每当新值出现在A列中时,它都需要重新启动以匹配的B列值作为列表中的第一个等等等等。
答案 0 :(得分:0)
记录下来,这是起作用的宏
Sub Delimit()
rownum = 3 'update to the correct starting row
outputRow = 1 'starting row for the output table
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
While rownum <= lastrow
SKU = Cells(rownum, "A")
delimited = Cells(rownum, "B")
rownum = rownum + 1
While (Cells(rownum, "A") = SKU Or Len(Cells(rownum, "A")) = 0) And rownum <= lastrow
delimited = delimited & "," & Cells(rownum, "B")
rownum = rownum + 1
Wend
Cells(outputRow, "D") = SKU 'change "D" to appropriate output column
Cells(outputRow, "E") = delimited 'change "E" to appropriate output column
outputRow = outputRow + 1
Wend
End Sub