PDA

View Full Version : Pasting into first empty row in a specific range



cerebralrust
06-01-2017, 04:43 AM
Hi guys,

I've seen several posts on how to paste into first empty row, however, I am trying my hardest to get this working appreciate your help.

I have one worksheet ( sheet1) which has three buttons Copy 1, copy 2 and copy3.

Copy1 is meant to copy values from cells in H22, I35 and K23 into S3, U3, and V3. Then Copy2 should copy into the next empty row in the table marked by S3 : V14.

I have written the following macro. But it pastes into the first empty row of the column S, U and V which I don't want. I just want to consider the first empty row of this subset S3:V14.


Sub CopyPaste()

Range("H22").Select
Selection.Copy
Range("S" & Lastrow1).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("K22").Select
Application.CutCopyMode = False
Selection.Copy
Range("U" & Lastrow2).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("F35").Select
Application.CutCopyMode = False
Selection.Copy
Range("V" & Lastrow3).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

Your help is greatly appreciated!

mdmackillop
06-01-2017, 06:38 AM
Please use code tags (# button) when posting code. Please read our FAQ

Maybe

Sub CopyPaste()
Dim LastRow As Long
LastRow = Cells(15, "S").End(xlUp)(2).Row
If LastRow <= 3 Then LastRow = 3
Cells(LastRow, "S") = Range("H22")
Cells(LastRow, "U") = Range("I35")
Cells(LastRow, "V") = Range("K23")
End Sub

mdmackillop
06-11-2017, 05:17 AM
Is this solved?