excel-vba 获取范围中最后一个单元格的行
示例
'if only one area (not multiple areas):
With Range("A3:D20")
Debug.Print.Cells(.Cells.CountLarge).Row
Debug.Print.Item(.Cells.CountLarge).Row 'using .item is also possible
End With 'Debug prints: 20
'with multiple areas (also works if only one area):
Dim rngArea As Range, LastRow As Long
With Range("A3:D20, E5:I50, H20:R35")
For Each rngArea In .Areas
If rngArea(rngArea.Cells.CountLarge).Row > LastRow Then
LastRow = rngArea(rngArea.Cells.CountLarge).Row
End If
Next
Debug.PrintLastRow 'Debug prints: 50
End With
热门推荐
10 部门过年祝福语简短独特
11 校庆祝福语简短横幅
12 周一祝福语简短精辟
13 给新生的简短祝福语
14 学生国庆简短的祝福语
15 共同祝福语简短的句子
16 天仙配简短祝福语
17 简短新年红包祝福语大全
18 康复儿童六一祝福语简短