|
zopey 发表于 2018-7-5 10:56
Function imatch(TargetVal As Range, TableArray As Range) As String
Dim icell As Range, rng As Range ...
‘修改如下
Function imatch(TargetVal As Range, TableArray As Range) As String
Dim icell As Range, rng As Range
Application.Volatile
imatch = "未匹配!"
Set rng = Intersect(TableArray, TableArray.Parent.UsedRange) '当区域取整列时,就最大返回可用区域内的单元格区域
n = rng.Rows.Count
m = rng.Columns.Count
For j = 1 To m
For i = 1 To n
If rng(i, j) <> "" Then
If InStr(TargetVal.Text, rng(i, j)) > 0 Then
imatch = rng(i, j)
Exit For
End If
End If
Next i
Next j
End Function
|
|