如何在Excel中的特定单元格中组合列值? [英] How do I combine column values in a specific cell in Excel?

查看:181
本文介绍了如何在Excel中的特定单元格中组合列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张表;

我希望能够列出这些选项与选项每个给定产品编号的单个单元格中的值如下所示:

I'd like to be able to list these Options with Options' Values in a single cell for every given Product ID like this one: Image

还要记住,我在表中列出了1800个产品ID,因此手动提取数据很漂亮

Also keep in mind that I have 1800 Product ID's listed in that table so manually extracting the data is pretty hard.

谢谢。

推荐答案

请尝试这种方法。

Sub Macro()
Dim lngRow As Long
For lngRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If StrComp(Range("A" & lngRow), Range("A" & lngRow - 1), vbTextCompare) = 0 Then
If Range("B" & lngRow) <> "" Then
Range("B" & lngRow - 1) = Range("B" & lngRow - 1) & "|" & Range("B" & lngRow)
End If
Rows(lngRow).Delete
End If
Next
End Sub

这篇关于如何在Excel中的特定单元格中组合列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆