|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Function 查找行列(sr, rng As Range, Optional x As Integer, Optional y As Integer)
' y= 0、默认,单元格绝对引用;1、查找列;2、查找行;3、单元格相对引用
Dim d As Object, arr, brr, v, xd, n%
arr = rng
Set d = CreateObject("Scripting.Dictionary")
For Each s In arr
d(i) = ""
Next
brr = d.keys
n = UBound(brr)
For Each s In rng
If s = sr Then '为精确查找
'If InStr(s, sr) Then 为模糊查找
n = n + 1
ReDim Preserve brr(0 To n)
brr(n) = s.Address
End If
Next
If Abs(x) > UBound(brr) Then 查找行列 = "": Exit Function
If x < 0 Then x = UBound(brr) + x + 1
v = Split(brr(x), "$")
查找行列 = Choose(y + 1, brr(x), v(1), v(2), v(1) & v(2))
End Function
老师:怎样编写 当第三参数【查找顺序】为空时,让计算结果返回返回空白?
|
|