|
代码如下。。。
Sub test()
Set wb = ThisWorkbook
Set sht = wb.Sheets("表一")
Set sh = wb.Sheets("表二")
Set d = CreateObject("scripting.dictionary")
arr = sh.UsedRange
brr = sht.UsedRange
ReDim crr(1 To UBound(brr), 1 To UBound(arr, 2))
For i = 2 To UBound(arr)
For j = 1 To UBound(arr, 2)
If arr(2, j) <> Empty Then d(arr(2, j)) = j
Next
Next
For i = 1 To UBound(brr, 2)
If brr(1, i) = "是否" Then x = i: Exit For
Next
For i = 2 To UBound(brr)
If brr(i, x) = "√" Then
n = n + 1
For j = 1 To UBound(brr, 2)
If d.exists(brr(1, j)) Then
crr(n, d(brr(1, j))) = brr(i, j)
End If
Next
End If
Next
sh.UsedRange.Offset(2).ClearContents
sh.UsedRange.Cells(3, 1).Resize(n, UBound(crr, 2)) = crr
Set d = Nothing
Beep
sh.Activate
End Sub
|
|