VBA - CopyData and Clear Contents

Jack_Amateur

New Member
Joined
Nov 18, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hey guys,
I'm new to VBA and trying to put together a sheet where staff can input data, click a button and it will copy the input on a table on another worksheet and clear the contents on the original sheet. I'm hoping that when the button is clicked again it adds the data to the table and so on.

I've only managed to make the MsgBox with Yes/No, your guidance is most appreciated.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The first part is understandable. Ok .. good so far.

But, what does this mean :

" I'm hoping that when the button is clicked again it adds the data to the table and so on."
 
Upvote 0
Apologies, silly me;
The copied data is compiled onto a table and continues to be added each time the button is clicked, whilst clearing the input sheet for new data.
 
Upvote 0
VBA Code:
Option Explicit

Sub CpyPste()

Application.ScreenUpdating = False

        Sheets("Input").Range("A2:D2").Copy
        
        Sheets("Table").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
        
        Sheets("Input").Range("A2:D2").Value = ""
        
        Sheets("Input").Range("A2").Select
        
        Application.CutCopyMode = False

Application.ScreenUpdating = True
End Sub

Download workbook : Copy Paste Other Sheet.xlsm
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,843
Members
449,471
Latest member
lachbee

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