|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub zldccmx()
- Dim Sh As Worksheet, Arr, Xls, Crr
- Crr = Sheets("查询").UsedRange
- Set Xls = GetObject(ThisWorkbook.Path & "\原始表.xls")
- Application.ScreenUpdating = False
- Set Sh = Xls.ActiveSheet
- Arr = Sh.UsedRange
- Xls.Close False
- Set Xls = Nothing
- Sheet2.[A2:D65536] = Empty
- brr = Sheet2.[A2:D65536]
- r = 1
- For j = 2 To UBound(Arr)
- If Arr(j, 23) = Crr(2, 1) Then
- brr(r, 1) = Arr(j, 21)
- brr(r, 2) = Arr(j, 22)
- brr(r, 3) = Arr(j, 23)
- brr(r, 4) = Arr(j, 24)
- r = r + 1
- End If
- Next
- r = r + 1
- For j = 2 To UBound(Arr)
- If Arr(j, 30) = Crr(3, 1) Then
- brr(r, 1) = Arr(j, 25)
- brr(r, 2) = Arr(j, 29)
- brr(r, 3) = Arr(j, 30)
- brr(r, 4) = Arr(j, 31)
- r = r + 1
- End If
- Next
- Sheet2.[a2].Resize(r - 1, 4) = brr
- Application.ScreenUpdating = True
- Sheet2.Activate
- End Sub
复制代码 |
|