|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim arr, brr, i&, j&, R&, m&, n&, strFind$, iBRow&, iERow&, iBCol&, iECol&, iPosRow&
strFind = Sheets(2).[B7]
If strFind = "" Then MsgBox "查找数据为空,请检查!": Exit Sub
arr = Sheets(1).UsedRange
ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
For i = 1 To 2 '
For j = 1 To UBound(arr, 2)
brr(i, j) = arr(i, j)
Next j
Next i
With Sheets(1)
For i = 1 To 2
R = 2: iBCol = (i - 1) * 6 + 1: iECol = (i - 1) * 6 + 5
For j = 3 To UBound(arr)
If arr(j, iBCol) = strFind Then
iBRow = j
iERow = IIf(.Cells(j, iBCol).End(xlDown).Row - 1 > UBound(arr), UBound(arr), .Cells(j, iBCol).End(xlDown).Row - 1)
For m = iBRow To iERow
R = R + 1
For n = iBCol To iECol
brr(R, n) = arr(m, n)
Next n
Next m
If R > iPosRow Then iPosRow = R
Exit For
End If
Next j
Next i
If iPosRow = 0 Then MsgBox "未查到数据": Exit Sub
Sheets(2).Range("A9:K9").Resize(1000).ClearContents
Sheets(2).[A9].Resize(iPosRow, UBound(brr, 2)) = brr
End With
End Sub
|
评分
-
2
查看全部评分
-
|