简体   繁体   中英

copy a row in one worksheet and paste in another worksheet

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:

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

.Range("A" & "k") should probably be .Range("A" & K) (ie lose the quotes around the letter 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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