简体   繁体   English

VBA Excel Range方法

[英]VBA Excel Range method

I need to move a row of data to another worksheet when a user chooses a value in a listbox. 当用户在列表框中选择一个值时,我需要将一行数据移动到另一个工作表中。 I am trying to use the following code to select the row on the new worksheet I want to move the data to: 我试图使用以下代码在新工作表上选择要将数据移动到的行:

'Move data to the "Red" worksheet
Sheets("Red").Range ("A11").Select

I am getting an "Object does not support this property or method" error. 我收到“对象不支持此属性或方法”错误。

What am I doing wrong? 我究竟做错了什么?

“范围”和“(”之间不应有空格。

  1. Is selecting allowed on your sheet? 您的工作表上是否允许选择? (= selection not prohibited by protection) (=选择不受保护禁止)
  2. I have noticed a space character between the word Range and ("A11"). 我注意到单词Range和(“ A11”)之间有一个空格字符。 This might have caused a syntax error. 这可能导致语法错误。

Use the macro recorder and manually perform the operation you want. 使用宏录制器并手动执行所需的操作。 Then you can look at the code recorded by Excel and clean it up to suit your needs. 然后,您可以查看Excel记录的代码并进行清理以适合您的需求。

The macro recorder is the easiest way to figure out whatever convoluted syntax VBA wants you to use. 宏记录器是找出VBA要使用的任何复杂语法的最简单方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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