nazanin
nazanin

Reputation: 183

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

Upvotes: 1

Views: 126

Answers (1)

barrowc
barrowc

Reputation: 10689

.Range("A" & "k") should probably be .Range("A" & K) (i.e. 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

Upvotes: 1

Related Questions