VBA替换函数
1 Sub test() 2 On Error Resume Next 3 Dim arr1, arr2, i, j 4 arr1 = Range("T1:EI3") 5 arr2 = Range("R9:EI14") 6 For i = 2 To UBound(arr2) 7 For j = 1 To UBound(arr1, 2) 8 If InStr(Join(Application.Transpose(Application.WorksheetFunction.Index(arr1, 0, j))), arr2(i, 1)) Then 9 arr2(i, j + 2) = "中" 10 Else 11 arr2(i, j + 2) = Val(arr2(i - 1, j + 2)) + 1 12 End If 13 Next j 14 Next i 15 Range("R9:EI14") = arr2 16 End Sub