懵懂的菜鸟

Stay hungry,Stay foolish.

导航

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

 

posted on 2017-08-16 11:04  懵懂的菜鸟  阅读(858)  评论(0编辑  收藏  举报