Copy and paste data to next blank cell using command button click

Dave Dunn

New Member
Joined
Nov 8, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I am using a Command Button that copies data from cell G3 to cell A3. I want to be able to copy the data to the next blank cell A4 to A14 in the column from cell G3. G3 data changes from a drop down list.

This is the code I have to do the first part which works as intended, but cannot figure how to paste data to the next blank cell. Your help would be greatly appreciated.

Private Sub CommandButton2_Click()

Application.ScreenUpdating = False

Dim xSheet As Worksheet

Set xSheet = ActiveSheet

If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs" Then

xSheet.Range("G3").Copy

xSheet.Range("A3").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


End If


Application.ScreenUpdating = True


End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try this:
VBA Code:
Sub Copy_Paste_Me()
'Modified 11/8/2022  10:32:57 PM  EST
Application.ScreenUpdating = False
Dim sn As String
sn = ActiveSheet.Name
Dim Lastrow As Long
Lastrow = Sheets(sn).Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets(sn).Range("G3").Copy
If Lastrow < 3 Then Lastrow = 3
Sheets(sn).Cells(Lastrow, 1).PasteSpecial
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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