Re: [算表] excel 从A表带资料到B表某字段

楼主: cutekid (可爱小孩子)   2023-10-17 12:00:10
VBA 解法:
Sub demo()
Set d = CreateObject("Scripting.Dictionary")
a = Sheets("A").UsedRange
For i = 1 To UBound(a)
For j = 1 To UBound(a, 2)
Key = a(i, j)
If Key = "" Then: Exit For
If d.exists(Key) Then: d(Key) = d(Key) & ","
d(Key) = d(Key) & a(i, 1)
Next
Next
With Sheets("B")
For i = 1 To .[a1].End(4).Row
.Cells(i, 2) = d(.Cells(i, 1).Value)
Next
End With
End Sub
※ 引述《chueight (baba)》之铭言:
: 软件:excel
: 版本:2016
: 各位神人身为铲表新手的我有个问题
: 有两表AB
: A表资料如下(已经整理成不同栏)
: 甲 1 2 3
: 乙 2 3
: 丙 4
: 丁 1 2 5
: B表资料如下
: 1
: 2
: 4
: 5
: 3
: 请问B表如何套用公式或vba 整理(两栏)
: 1 甲,丁
: 2 甲,乙,丁
: 4 丙
: 5 丁
: 3 甲,乙
: 以上虚心受教,感谢ptt
:
作者: chueight (baba)   2023-10-31 14:59:00
再谢一次!

Links booklink

Contact Us: admin [ a t ] ucptt.com