|
楼主 |
发表于 2018-3-16 22:32
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Private Sub Worksheet_Change(ByVal Target As Range)
- On Error Resume Next
- If Target.Address <> "$D$5" Then Exit Sub
- Dim arr, brr, rng As Range, r, r1, r2, i, j, k
- With Sheets("主件清单")
- r = .[B65536].End(xlUp).Row
- For Each rng In .Range("A2:A" & r)
- If rng.Value = Target.Value Then
- r1 = rng.Row + 1
- ReDim brr(1 To 20, 1 To 6)
- k = 0
- For i = r1 To r
- If .Cells(i, 2) <> "" Then
- k = k + 1
- brr(k, 1) = .Cells(i, 2)
- For c = 3 To 6
- brr(k, c) = .Cells(i, c)
- Next
- Else
- Exit For
- End If
- Next
-
- End If
- Next
- End With
- Range("C8:L21").ClearContents
- Range("C8").Resize(k, 6) = brr
- End Sub
复制代码 |
|