Find second empty cell/row and start pasting from it

Closed
scafy Posts 1 Registration date Wednesday September 17, 2014 Status Member Last seen September 17, 2014 - Sep 17, 2014 at 10:23 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Sep 23, 2014 at 11:32 AM
I've already did a lot of research and couldn't find a solution. I'm trying to find the second empty cell/row (or other especified cell) in a column and start pasting from it (always jumping to next empty cell/row). I found the code below, but it starts pasting from the first empty row in a column. Changing the offset command to (2,0) doesn't work too because it finds the second empty row but starts pasting always leaving a empty cell between the collages. And I want to find the second empty cell only in the beginning and from there start pasting always in the next first empty cell/row. Can you guys help me please? Thanks a lot in advance!

For example, I'm copying the range G4:I4 and trying to paste into column G.

Code:

Sub InsertButton()
Range("G4:I4").Copy Range("G" & Rows.Count).End(xlUp).Offset(1, 0)
End Sub
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Sep 23, 2014 at 11:32 AM
Hi Scafy,

Well you could just use two codes, but you can also try this:
Dim Check As Boolean
Sub InsertButton()

If Check = False Then
    Range("G4:I4").Copy Range("G" & Rows.Count).End(xlUp).Offset(2, 0)
    Check = True
Else
    Range("G4:I4").Copy Range("G" & Rows.Count).End(xlUp).Offset(1, 0)
End If

End Sub


Best regards,
Trowa

0