Excel 如何选择最后一行

Excel 如何选择最后一行,excel,vba,Excel,Vba,我有一张excel表格,其中包含以下数据: A B C D E F 1 10 11 12 78 45 2 12 15 15 78 45 3 17 18 13 7 45 4 12 45 7 78 78 5 578 54 45 8 78 6 42

我有一张excel表格,其中包含以下数据:

    A      B      C     D     E      F           
1   10     11     12    78    45

2   12     15     15    78    45

3   17     18     13    7     45

4   12     45     7     78    78

5   578    54     45    8     78

6   42     72     75    8     78

7   452    22252  2277  87    986

8   752    72     752   878   98638

9   72     72     72    45    78

10  788    72     78    678   465
现在,我想选择excel中的最后一行。因为每天行号都会改变。
但是我不想要
选择.End(xlToRight)。选择
,因为在这个excel中,每两列后面都会出现空格。
例:

我想选择A10作为此行的最后一个单元格

我已经创建了“usedrange”方法,但它对我来说并不好用

startcell = Range("B" & Cells.Rows.Count).End(xlUp).Select
endrcell = Range("G" & Cells.Rows.Count).End(xlUp).Select
如何选择带空格的起始单元格到结束单元格

请给出建议。

这个怎么样:

Sub GetLastRow()
    Dim rng As Range, lastRow As Long, col As Long

    lastRow = Range("A1").End(xlDown).Row //Get last row in column A
    col = Range("XFD" & lastRow).End(xlToLeft).Column //Get last used column in last row

    Set rng = Range(Cells(lastRow, 1), Cells(lastRow, col))
End Sub

若要选择带有数据的最后一行,请首先从底部向上移动以查找该行,然后在该行上向左移动以查找最后使用的列:

Sub SelectLastRow()
    Dim nRow As Long, nColumn As Long
    nRow = Cells(Rows.Count, "A").End(xlUp).Row
    nColumn = Cells(nRow, Columns.Count).End(xlToLeft).Column
    Range(Cells(nRow, "A"), Cells(nRow, nColumn)).Select
End Sub
可能重复的