user3705100
user3705100

Reputation: 45

How to copy Range and past to last row

I have a user input transaction information (Name, Amount, Date) in cells E33:G33.

User clicks button and the transaction is recorded in the last row +1 used in a Transaction history list starting on E46:G46.

So far my code doesnt work.

i want simply: -copy range (E33:G33) -find last row used in column E -go one row lower -past the copied range

Cant find a working answer, please help! Thanks.

Upvotes: 0

Views: 97

Answers (1)

Vasily
Vasily

Reputation: 5782

use this:

Sub test()
Dim e&: e = Cells(Rows.Count, "E").End(xlUp).Row + 1
Range("E" & e & ":G" & e).Value = [E33:G33].Value 'past only values
End Sub

or

Sub test2()
Dim e&: e = Cells(Rows.Count, "E").End(xlUp).Row + 1
[E33:G33].Copy Range("E" & e & ":G" & e) 'past with cells format
End Sub

or

Sub test3()
Dim e&: e = Cells(Rows.Count, "E").End(xlUp).Row + 1
[E33:G33].Copy
Range("E" & e & ":G" & e).PasteSpecial xlPasteAll 'past with cells format
End Sub

or

Sub test4()
Dim e&: e = Cells(Rows.Count, "E").End(xlUp).Row + 1
[E33:G33].Copy
Range("E" & e & ":G" & e).PasteSpecial xlPasteValues 'past only values
End Sub

also:

[E33:G33] can be replaced by:

Range("E33:G33")

or

Cells(Cells(33,"E"),Cells(33,"G"))

or

Cells(Cells(33,5),Cells(33,7))

Upvotes: 1

Related Questions