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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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,215,489
Messages
6,125,093
Members
449,205
Latest member
ralemanygarcia

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