EXCEL表一张是班上孩子名单,一张是全校孩子发表的作文名单,怎样快速找出发表作品的孩子并把名字附在后面

2025-01-06 05:26:43
推荐回答(2个)
回答1:

=text(vlookup(A2,sheet2!A:C,3,),"yyyy-m-d")&vlookup(A2,sheet2!A:C,2,)就有日期了,但也完成不了你的多个作文,如果要多个作文,可以用VBA处理。
代码如下
Sub test()
Dim arr, brr, str1$, x&, y&
With Sheets("sheet2")
arr = .Range("A2:C" & .Range("A65536").End(xlUp).Row)
End With
With Sheets("sheet1")
brr = .Range("A2:B" & .Range("A65536").End(xlUp).Row)
For x = 1 To UBound(brr)
str1 = ""
For y = 1 To UBound(arr)
If arr(y, 1) = brr(x, 1) Then
If str1 = "" Then
str1 = arr(y, 3) & arr(y, 2)
Else
str1 = str1 & "," & arr(y, 3) & arr(y, 2)
End If
End If
Next y
brr(x, 2) = str1
Next x
.Range("A2").Resize(UBound(brr), 2) = brr
End With
End Sub
运行这个宏就得到结果,用数组来处理,主要是考虑到运行速度

回答2:

=text(vlookup(A2,sheet2!A:C,3,),"e-m-d")&vlookup(A2,sheet2!A:C,2,)
可以的话把表格发给我帮你做!
815850733@QQ.COM