Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Copy/Paste data – Copy the Entire data from one sheet to another

In VBA-Excel, Copy and paste the data plays an important role, we can copy data from one place and paste it at some other place in the same way like how we do it manually, and when you copy some data its goes to the Clipboard from there you can paste it at some other location.

Dim mainworkBook As Workbook

Set mainworkBook = ActiveWorkbook

Copy  the Entire data from one sheet to another

For example if you want to copy the data “Sheet1” and paste it to in “Sheet2”.

For copy the data present in “Sheet1”

mainworkBook.Sheets(“Sheet1”).UsedRange.Copy

now the data has been copied to clipboard, you can check it by manually pasting it in a notepad.

Now select the cell in which you want to paste the data, in this example its “B2” in “Sheet2”

mainworkBook.Sheets(“Sheet2”).Select

mainworkBook.Sheets(“Sheet2”).Range(“A1”).Select

Now paste the data

mainworkBook.Sheets(“Sheet2”).Paste

 

You may also like...

3 Responses

  1. AMIT says:

    I wanted to create a macro and my requirment is :-

    1) copy the data from a different workshhet to one sheet.
    2) The copied data one row into another sheet row with down (So previous data dose not changed)

    • SJ says:

      1. Copy the data from sheet , ex: Sheets(“Sheet1”).UsedRange.copy
      2. Now you need t paste the data in such a way that previous data is not changed, so you need to select the row which is first blank row available
      3. int usedRows = Sheets(“Sheet2”).UsedRange.Rows.Count
      4. Sheets(“Sheet2”).Range(usedRows+1).Select OR Sheets(“Sheet2”).Range(usedRows+1).Paste
      Now previous data will not be lost

      Please let me know if this does not work.

  2. Mark says:

    This worked out great. Thanks!!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: