选择整行数据 [英] Selecting entire row of data

查看:148
本文介绍了选择整行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一行数据(A3到A11),我想选择(在这个范围内没有空格)。我使用以下代码:

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

但是,此代码只选择单元格A3而不是A3 A11。我也尝试过xlToLeft,而且仍然只选择A3,我该如何更正?谢谢。

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.

推荐答案

只是因为你的标题,这里有几种方法来选择一行

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

同样在你的例子中,你缺少ws。前缀从最外面的范围对象 - 没有指定工作表,Excel将尝试引用ActiveSheet,你刚才写了一个潜在的错误。

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.

这篇关于选择整行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆