excel - 根据 A 列数据将不同数量的 B 列单元格中的数据转换为单个逗号分隔的行
问题描述
我需要重新格式化从 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 都有不同数量的图像。我需要将所有 url 放在一行中的逗号分隔列表中(与 sku 相同),然后每当 A 列中出现新值时,它需要以匹配的 B 列值作为列表中的第一个重新启动等等等等。
解决方案
作为记录,这是有效的宏
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
推荐阅读
- testing - 通过“npm install”安装时找不到 Testcafe 命令
- android - 从其他屏幕返回后导航抽屉打开
- android - 如何让 SMS Retriever API 监听多条短信
- angular - 带有身份服务器的 Angular 6 SPA - 存储令牌
- node.js - tls/certificate (SMTP) 的 Nodemailer 问题
- jmeter - 如何在 jmeter 中使用 SMTP 服务器发送电子邮件
- php - Getting post featured image on different page
- vue.js - Vue.js 中的 Select2 未定义
- angular - 如何将图像加入数组并在 Angular 的滑块中显示它们
- javascript - 删除文件路径和文件名,使用 Node 将文件名留在 AWS Lambda 中