查找非连续范围中的最后一列和最后一行

时间:2017-12-12 10:57:11

标签: vba excel-vba excel

我希望能够在不使用UsedRange的情况下快速找到非连续数据范围的最右列和最后一行。我没有找到比这种方法更快的方法。有什么想法吗?

Function Range_Find_Method(ws As Worksheet)
Dim lRow As Long
Dim lCol As Long

With ws
    lRow = .Cells.Find(What:="*", _
                    After:=.Range("A1"), _
                    LookAt:=xlPart, _
                    LookIn:=xlFormulas, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious, _
                    MatchCase:=False).Row

    lCol = .Cells.Find(What:="*", _
                    After:=.Range("A1"), _
                    LookAt:=xlPart, _
                    LookIn:=xlFormulas, _
                    SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious, _
                    MatchCase:=False).Column
End With

Debug.Print lRow
Debug.Print lCol

end function

谢谢

0 个答案:

没有答案
相关问题