Excel VBA判断数据最后一行或者列

通过 | 21 1 月, 2022

判断最后一列的函数
Function LastColumn() As Long
Dim ix As Long
ix = ActiveSheet.UsedRange.Column – 1 + ActiveSheet.UsedRange.Columns.Count
LastColumn = ix
End Function

判断最后一行的函数
Function LastRow() As Long
Dim ix As Long
ix = ActiveSheet.UsedRange.Row – 1 + ActiveSheet.UsedRange.Rows.Count
LastRow = ix
End Function

发表回复