Paste into next free row

seang87

New Member
Joined
Oct 22, 2014
Messages
11
Hi All,

I have the following running on inserted check boxes, which I'm mostly happy with. The issue I have is the values paste to sheet 2 and override the previous values.

I need the values to paste in the next free empty row on sheet2, there may be others rows in sheet2 with values that need to remain. But I need this to look and paste in the next free empty row.


Here is the example, I will have around 30 check boxes through the sheet

Sub T2_Click()


Dim LastRow1 As Long
Dim LastRow As Long
Dim LastCol As Long
Dim sh As Worksheet



Set sh = Sheets("Sheet1")



LastCol = Sheets("Sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
LastRow1 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row


Range(sh.Cells(2, 1), sh.Cells(2, "Q")).Copy Destination:=Sheets("Sheet2").Range("A" & LastRow1 + 1)
Range(sh.Cells(2, 1), sh.Cells(2, "P")).ClearContents



End Sub






Sub T3_Click()




Dim LastRow1 As Long
Dim LastRow As Long
Dim LastCol As Long
Dim sh As Worksheet

Set sh = Sheets("Sheet1")

LastCol = Sheets("Sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
LastRow1 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row


Range(sh.Cells(2, 1), sh.Cells(3, "Q")).Copy Destination:=Sheets("Sheet2").Range("A" & LastRow1 + 1)
Range(sh.Cells(2, 1), sh.Cells(3, "P")).ClearContents


End Sub



Thanks!!!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi seang87,
Try the bold print line.

Regards,
Howard


Code:
Sub T2_Click()


 Dim LastRow1 As Long
 Dim LastRow As Long
 Dim LastCol As Long
 Dim sh As Worksheet



 Set sh = Sheets("Sheet1")



 LastCol = Sheets("Sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
 LastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
 LastRow1 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row


' Range(sh.Cells(2, 1), sh.Cells(2, "Q")).Copy Destination:=Sheets("Sheet2").Range("A" & LastRow1 + 1)

 [B]Range(sh.Cells(2, 1), sh.Cells(2, "Q")).Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)(2)

 Range(sh.Cells(2, 1), sh.Cells(2, "P")).ClearContents
[/B]


 End Sub
 
Upvote 0
Does sheet 2 have anything in column A.

The paste line code refers to column A, first blank cell coming up from the bottom.


Howard

Edit.. Just read your last post.

Great.

FYI: You can use (1) to copy over last entry, (2) to copy to first blank cell, (3) will leave a blank row between copies.

H
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,128
Messages
6,129,036
Members
449,482
Latest member
al mugheen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top