VBA Copy Paste on next blank row below

XL User

New Member
Joined
Apr 11, 2018
Messages
8
Hi all,

I'm quite new to VBA/Macros, & I'm trying to paste certain values from one tab to another tab on the same worksheet. What I have so far:


Sub LogButton()


Worksheets("Coaching Form").Range("I8").Copy
Worksheets("Database").Range("A2").PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C8").Copy
Worksheets("Database").Range("B2").PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C10").Copy
Worksheets("Database").Range("C2").PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C9").Copy
Worksheets("Database").Range("D2").PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C11").Copy
Worksheets("Database").Range("E2").PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("I10").Copy
Worksheets("Database").Range("F2").PasteSpecial xlPasteValues
Application.CutCopyMode = False


End Sub

How can I make this so that it pastes onto the next blank row below the non-blank one?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this:
Code:
Sub LogButton()
'Modified 6/21/18 2:15 AM EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Sheets("Database").Cells(Rows.Count, "A").End(xlUp).Row + 1
Worksheets("Coaching Form").Range("I8").Copy
Worksheets("Database").Range("A" & Lastrow).PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C8").Copy
Worksheets("Database").Range("B" & Lastrow).PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C10").Copy
Worksheets("Database").Range("C" & Lastrow).PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C9").Copy
Worksheets("Database").Range("D" & Lastrow).PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("C11").Copy
Worksheets("Database").Range("E" & Lastrow).PasteSpecial xlPasteValues
Worksheets("Coaching Form").Range("I10").Copy
Worksheets("Database").Range("F" & Lastrow).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Here's some alternative code :
Code:
Sub LogButton()
Dim r%, cel As Range, c%
r = Sheets("Database").Cells(Rows.Count, "A").End(xlUp).Row + 1
For Each cel In Sheets("Coaching Form").[I8,C8,C10,C9,C11,I10]
    c = c + 1
    Sheets("Database").Cells(r, c).Value = cel
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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