|
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Target.Column = 5 And Target.Row > 7 Then
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim arr, n%, i&, s&
- x = Target.Offset(0, -2)
- Workbooks.Open (ThisWorkbook.Path & "\消耗模式统计\物料消耗.xls")
- arr = Sheets("消耗").Range("a2").CurrentRegion
- Sheets(2).UsedRange.Clear
- n = UBound(arr, 2)
- For i = 2 To UBound(arr)
- If arr(i, 1) = x Then s = s + 1: Sheets("消耗").Cells(i + 1, 1).Resize(1, n).Copy Sheets(2).Cells(s + 4, 1)
- Next
- Workbooks("物料消耗.xls").Close 1
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End If
- End Sub
复制代码 |
|