|
- Option Explicit
- Sub Main()
- Dim arr, brr()
- Dim i, j, tgt As Integer
- Dim cond1, cond2 As Boolean
- arr = Sheet1.Range("B3").CurrentRegion
- For i = 1 To UBound(arr)
- cond1 = (CInt(arr(i, 3)) >= 40) And (CInt(arr(i, 3)) <= 49)
- cond2 = (CInt(arr(i, 5)) >= 40) And (CInt(arr(i, 5)) <= 49)
- If cond1 Or cond2 Then
- tgt = tgt + 1
- ReDim Preserve brr(1 To 5, 1 To tgt)
- For j = 1 To 5
- brr(j, tgt) = arr(i, j)
- Next j
- End If
- Next i
- Sheet2.UsedRange.ClearContents
- Sheet2.Range("A3").Resize(UBound(brr, 2), UBound(brr)) = WorksheetFunction.Transpose(brr)
- Sheet2.Activate
- MsgBox "程序运行完毕"
- End Sub
复制代码
|
|