vbscript 查找范围中的最后一列

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 查找范围中的最后一列相关的知识,希望对你有一定的参考价值。

Function FindLastColumnInRange(rng As Range) As Long
'Description: finds the last column in a range
'Inputs:      Range
'Outputs:     column number (long); zero if error occured

'   check range
    If rng Is Nothing Then Exit Function

        On Error Resume Next
        FindLastColumnInRange = Application.WorksheetFunction.Max( _
                                rng.Find(What:="*", _
                                After:=rng.Cells(1), _
                                LookAt:=xlPart, _
                                LookIn:=xlFormulas, _
                                SearchOrder:=xlByColumns, _
                                SearchDirection:=xlPrevious, _
                                MatchCase:=False).Column, _
                                rng.Find(What:="*", _
                                After:=rng.Cells(1), _
                                LookAt:=xlPart, _
                                LookIn:=xlFormulas, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlPrevious, _
                                MatchCase:=False).Column)
        On Error GoTo 0

End Function

以上是关于vbscript 查找范围中的最后一列的主要内容,如果未能解决你的问题,请参考以下文章