代码如下。。。
Private Sub CommandButton1_Click()
arr = Range("a1").CurrentRegion
ReDim brr(1 To UBound(arr) - 1, 1 To 3)
hl = [a1].Value
For i = 2 To UBound(arr)
bj = Empty
For j = 5 To UBound(arr, 2) Step 3
If arr(i, j) <> "" Then
arr(i, j) = IIf(arr(i, j + 1) = "USD", arr(i, j) * hl, arr(i, j))
If arr(i, 1) = "高" Then
If bj <> Empty Then
If bj < arr(i, j) Then
brr(i - 1, 1) = arr(i, j)
brr(i - 1, 2) = arr(i, j + 1)
brr(i - 1, 3) = arr(i, j + 2)
End If
Else
bj = arr(i, j)
brr(i - 1, 1) = arr(i, j)
brr(i - 1, 2) = arr(i, j + 1)
brr(i - 1, 3) = arr(i, j + 2)
End If
Else
If bj <> Empty Then
If bj > arr(i, j) Then
brr(i - 1, 1) = arr(i, j)
brr(i - 1, 2) = arr(i, j + 1)
brr(i - 1, 3) = arr(i, j + 2)
End If
Else
bj = arr(i, j)
brr(i - 1, 1) = arr(i, j)
brr(i - 1, 2) = arr(i, j + 1)
brr(i - 1, 3) = arr(i, j + 2)
End If
End If
End If
Next
Next
[b2].Resize(UBound(brr), 3) = brr
Beep
End Sub
|