'可能是这意思?
Option Explicit
Sub detention()
Dim arr
arr = [k1:k5]: Call judge(arr)
[k1].Offset(, UBound(arr, 2)).Resize(UBound(arr, 1), UBound(arr, 2)) = arr
End Sub
Function judge(arr)
Dim i, j
For i = 1 To UBound(arr, 1)
For j = 1 To UBound(arr, 2)
If arr(i, j) = "D20" Or arr(i, j) = "22GP" Or arr(i, j) = "22G1" Then
arr(i, j) = "D20"
ElseIf arr(i, j) = "D40" Or arr(i, j) = "42GP" Then
arr(i, j) = "D40"
ElseIf arr(i, j) = "D40H" Or arr(i, j) = "45GP" Or arr(i, j) = "40HC" Then
arr(i, j) = "D40H"
ElseIf arr(i, j) = "D45H" Or arr(i, j) = "45HC" Then
arr(i, j) = "D45H"
Else
arr(i, j) = "请查看箱型是否错误"
End If
Next j, i
End Function |