|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
俺是个新手刚学VBA没多长时间,试着写了一个宏,能运行,就是扩展性差,要用到其他的数据上可能需要改里面的一些参数:
Sub tianchong()
Dim a As Range, b As String, c As String
b = Worksheets("筛选数据").Cells(1, "A").End(4).Row
c = Worksheets("原始数据").Cells(1, "A").End(4).Row
For j = 3 To b
Set a = Worksheets("筛选数据").Cells(j, "B")
For i = 3 To c
If a.Value = Worksheets("原始数据").Cells(i, "B").Value Then
a.Offset(0, 1).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 1)
a.Offset(0, 2).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 2)
a.Offset(0, 3).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 3)
a.Offset(0, 4).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 4)
a.Offset(0, 5).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 5)
a.Offset(0, 6).Value = Worksheets("原始数据").Cells(i, "B").Offset(0, 6)
End If
Next
Next
End Sub |
|