Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to paste in last row of Column B in excel?

Tags:

excel

vba

I need to cut cells from H2:L2 to all the way down and paste it in last row of column B.

Data will be different everytime so I cannot hard code any range.

VBA code would be nice, to cut from H2:L2 down and paste/insert in the last row of Column B.

So far I got.

Range("H2:L2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
like image 264
Mowgli Avatar asked Oct 25 '25 07:10

Mowgli


1 Answers

Here is a segment of code that should accomplish what you are looking for.

Start code including your cut segment...
Dim lastRow As String

lastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row + 1
Range("B" & lastRow).Select
Selection.PasteSpecial
Rest of code...

There are a number of books that will help with this type of coding and have step by step trainig. I am partial to the series published by Microsoft "Step by Step" series. Best of luck!

like image 184
Desert Spider Avatar answered Oct 27 '25 23:10

Desert Spider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!