VBA code to paste in next empty cell of a column

rrodwell85

New Member
Joined
Apr 18, 2016
Messages
5
I am trying to compute a score of players based on a macro with a series of checkboxes. The output values of the check boxes are pasted on the "Calculations" worksheet where the score is then computed in cell F18. I would like to copy cell F18 and paste it in the next empty cell of column D on the worksheet of players. So far I have this code:

Dim LastRow As Long
LastRow = Sheets("Players").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row


Sheets("Calculations").Range("F18").Copy
Sheets("Players").Cells(LastRow, 1).PasteSpecial xlPasteValues

This code works great but how can I modify it to paste in COLUMN D of the Players worksheet????
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi,
welcome to the board.

If just want to copy value from one cell to another then following change to your code should do what you want.

Code:
Sheets("Players").Cells(Cells(Rows.Count, 4).End(xlUp).Row + 1, 4).Value = _
Sheets("Calculations").Range("F18").Value

Dave
 
Upvote 0
Hi. And welcome to the board.
Your Line:
Sheets("Players").Cells(LastRow, 1).PasteSpecial xlPasteValues
tells it to paste in row 'LastRow' column 1 (A).


To get it to paste in column D, simply change your 1 to a 4. (column D... 4th column)
Sheets("Players").Cells(LastRow, 4).PasteSpecial xlPasteValues


(Note though that, above, the variable 'LastRow' is still being defined as the last used row in column A.)


Hope it helps.
 
Upvote 0
Hi. And welcome to the board.
Your Line:
Sheets("Players").Cells(LastRow, 1).PasteSpecial xlPasteValues
tells it to paste in row 'LastRow' column 1 (A).


To get it to paste in column D, simply change your 1 to a 4. (column D... 4th column)
Sheets("Players").Cells(LastRow, 4).PasteSpecial xlPasteValues


(Note though that, above, the variable 'LastRow' is still being defined as the last used row in column A.)



Hope it helps.


THANK YOU! It worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,664
Members
449,114
Latest member
aides

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