|
楼主 |
发表于 2020-3-12 08:32
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 YZC51 于 2020-3-13 07:55 编辑
请参考
返回最后非空数据和单元格地址.rar
(21.74 KB, 下载次数: 15)
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 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 |
评分
-
2
查看全部评分
-
|