简体   繁体   中英

Excel VBA Select all cells down

I'm looking to select every cell below a certain cell (not only in my list). I know of xldown, but this doesn't work in the instance of blanks, which occur in my list.

Is this possible?

The follow will select all cells from A1 down to the last cell in column A that's not empty :

Sub select_all()
  Range(Cells(1, 1), Cells(Range("A1000000").End(xlUp).Row, 1)).Select
End Sub

You can modify the column / range to fit in your situation. Noted that it is hardcoded to assume 1000000 or less rows being used.

This will select A9 to column A the last row with data:

Range("A9:A" & range("A" & rows.Count).End(xlUp).Row).select

Just change A and 9 to whatever column and row you want.

I am interested to know what your next line of code is though as .select can most probably be ommited and the command can be performed directly without a select.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM