this is the code and i don't know what is wrong that it fail ? i think i couldn't define a range that changes the aim is to copy a selected row from one worksheet to the end of another worksheet...row.counts and so on didn't work at all ! i don't know why ...i am using excel2007 and vba version is 6.5 and i don't know if i can upgrade it to better version?this is the code:
这是代码,我不知道它出了什么问题?我认为我不能定义一个范围来改变目标,那就是将选定的一行从一个工作表复制到另一个工作表的末尾…行。计数等等根本不起作用!我不知道为什么……我正在使用excel2007和vba版本是6.5,不知道是否可以升级到更好的版本?这是代码:
K = 2
For i = 1 To LastLine
If Cells(i, 2).Value = longti Then
Rows(i).Select
Selection.Copy
Worksheets("result").Range("A" & "k").PasteSpecial (xlPasteValues)
thank you for help . i don't know if question is clear or not
谢谢你的帮助。我不知道问题是否清楚
1 个解决方案
#1
1
.Range("A" & "k")
should probably be .Range("A" & K)
(i.e. lose the quotes around the letter K)
.Range("A" & "k")应该是。range ("A" & k)
As you have it now, the code is looking for a range with address "Ak" which doesn't make sense. The amended code will look for a range with address "A2" which is probably what you want
正如您现在所看到的,代码正在寻找一个包含地址“Ak”的范围,这是没有意义的。修改后的代码将查找地址“A2”的范围,这可能正是您想要的
#1
1
.Range("A" & "k")
should probably be .Range("A" & K)
(i.e. lose the quotes around the letter K)
.Range("A" & "k")应该是。range ("A" & k)
As you have it now, the code is looking for a range with address "Ak" which doesn't make sense. The amended code will look for a range with address "A2" which is probably what you want
正如您现在所看到的,代码正在寻找一个包含地址“Ak”的范围,这是没有意义的。修改后的代码将查找地址“A2”的范围,这可能正是您想要的