|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 按钮1_Click()
arr = Sheets(1).UsedRange
brr = Sheets(2).UsedRange
For j = 2 To UBound(brr)
For i = 7 To UBound(brr, 2) Step 3
If Len(brr(j, i - 1)) > 0 Then
For k = 2 To UBound(arr, 2) Step 2
If InStr(arr(1, k), brr(j, i - 2)) > 0 Then
If InStr(arr(2, k), brr(j, 3)) > 0 Then
c = k
Else
c = k + 1
End If
For m = 3 To UBound(arr)
If InStr(arr(1, k), "秒") = 0 Then
If Val(brr(j, i - 1)) >= Val(arr(m, c)) Then
brr(j, i) = arr(m, 1)
Exit For
End If
Else
If Val(brr(j, i - 1)) <= Val(arr(m, c)) Then
brr(j, i) = arr(m, 1)
Exit For
End If
End If
Next m
Exit For
End If
Next k
End If
Next i
Next j
Sheets(2).UsedRange = brr
End Sub
|
|