Excel VBA 将范围复制到表格中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20437455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel VBA Copy range into table
提问by user2005990
I have been unable to figure out how to paste a range (specifically one row) into a data table using VBA.
我一直无法弄清楚如何使用 VBA 将范围(特别是一行)粘贴到数据表中。
Right now there is a range of data in a worksheet named "RawData". On another sheet there is a graph that starts at (1, 1) and goes to (100, 33). The variable ThisValue contains the name of the sheet containing the table. The variable x contains the row number of the range I am attempting to transfer.
现在,名为“RawData”的工作表中有一系列数据。在另一张纸上有一个从 (1, 1) 开始到 (100, 33) 的图。变量 ThisValue 包含包含表格的工作表的名称。变量 x 包含我尝试传输的范围的行号。
I am currently using this code:
我目前正在使用此代码:
Sheets("RawData").Select
Cells(x, 1).Resize(1, 33).Copy
Sheets(ThisValue).Select
NextRow = Cells(Rows.Count, 1).End(xlUp).row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
The problem that I am facing is that it pastes the range of data directly below the table and not in the table. Any help would be greatly appreciated.
我面临的问题是它将数据范围直接粘贴在表格下方而不是表格中。任何帮助将不胜感激。