|
- Sub Click01()
- Range("a5:z65536") = ""
- Dim arr, arr1, arr2
- Dim Wb As Workbook
- Dim Temp As String
- Dim r&, j%
- arr1 = Sheet2.UsedRange
- Application.ScreenUpdating = False
- Temp = ThisWorkbook.Path & "\清单.xls"
- Set Wb = GetObject(Temp)
- With Wb.Sheets("问卷")
- arr2 = .UsedRange
- ReDim arr(1 To UBound(arr2), 1 To UBound(arr1, 2))
- ReDim brr(1 To UBound(arr2), 1 To UBound(arr1, 2))
- For i = 1 To UBound(arr1, 2)
- For j = 1 To UBound(arr2, 2)
- If arr2(3, j) = arr1(3, i) And arr2(3, j) <> "" Then
- For h = 5 To UBound(arr2)
- arr(h - 4, i) = arr2(h, j)
- Next
- ElseIf arr2(4, j) = arr1(4, i) And arr2(3, j) = "" Then
- For h = 5 To UBound(arr2)
- brr(h - 4, i) = arr2(h, j)
- Next
- End If
- Next
- Next
- End With
- Wb.Close False
- Set Wb = Nothing
- ReDim crr(1 To UBound(arr2), 1 To UBound(arr1, 2))
- For x = 1 To UBound(crr)
- For y = 1 To UBound(crr, 2)
- If arr(x, y) <> "" Or brr(x, y) <> "" Then
- crr(x, y) = arr(x, y) + brr(x, y)
- End If
- Next y
- Next x
- Sheet2.[a5].Resize(UBound(crr), UBound(crr, 2)) = crr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|