Selecting entire row of data

2019-08-11 09:00发布

I have a row of data (A3 to A11) that I would like to select (there are no blanks in this range). I am using the following code:

Range(ws.Range("A3"), ws.Range("A3").End(xlToRight)).Select

However, this code is only selecting cell A3 and not A3 to A11. I have also tried xlToLeft and that still only selects A3 as well...How can I correct this? Thanks.

7条回答
Explosion°爆炸
2楼-- · 2019-08-11 09:27

Just because of your title, here are a couple ways to select a row

ws.Rows(3).Select
ws.Range("a3").EntireRow.Select

to select all the data on a row,

ws.Range("A3",ws.Cells(3,ws.Columns.Count).End(xlToLeft)).Select

Also in your example, you're missing the "ws." prefix from the outermost range object - without specifying the worksheet, Excel will try to refer to the ActiveSheet and you've just written a potential bug.

查看更多
你好瞎i
3楼-- · 2019-08-11 09:32

I think this overlaps with Populating a list box with data from worksheet. I suggest you continue any issues related to this thread back in the original posting

As per prior question to select vertically you use xlDown and xlUp (not xltoRight or xltoLeft)

ws.Range(ws.[a3], ws.Cells(Rows.Count, "A").End(xlUp))
查看更多
乱世女痞
4楼-- · 2019-08-11 09:38

You need to select range from A3 to A11. This would do the trick

  activesheet.range("A3:A11").select  or
  activesheet.range(cells(3,"A"),cells(11,"A")).select  or
  activesheet.range(cells(3,1),cells(11,1)).select 
查看更多
叛逆
5楼-- · 2019-08-11 09:40

Try This...

ActiveSheet.UsedRange.EntireRow.Select

查看更多
Deceive 欺骗
6楼-- · 2019-08-11 09:41
RANGE("A1", Cells(RANGE("A23").row, Columns.Count).End(xlToLeft)).Select    'YES
查看更多
别忘想泡老子
7楼-- · 2019-08-11 09:54

How about:

a = Range("A11").End(xlToRight).Address
Range("A3:" & a).Select
查看更多
登录 后发表回答