How do I copy data from one excel sheet to another excel sheet?

user7444699

This code just opens the source file but doesn't copy anything from it. I want to copy the data from my source file and paste it to the destination file.

Sub copy()

Dim x As Workbook
Dim y As Workbook

Set x = Workbooks.Open("Source File")
Set y = Workbooks.Open("Destination File")

y.Sheets("Sheet1").Range("A1").Value = x.Sheets("Sheet1").Range("A1")

x.Close

End Sub
user8753746

You are missing .Value ant the end of your line:

y.Sheets("Sheet1").Range("A1").Value = x.Sheets("Sheet1").Range("A1").Value

Or Try:

y.Sheets(1).Cells(1, 1).Value = x.Sheets(1).Cells(1, 1).Value

I guess you don't have Sheet1 in both workbook, so lets try different notation.

Try debugging your code with:

msgbox y.Sheets("Sheet1").Range("A1").Value
msgbox x.Sheets("Sheet1").Range("A1").Value

I guess your files are not being opened properly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to copy only formulas from one excel sheet which can dynamically grow to another sheet using macro

From Dev

Copy data from one excel sheet to another (complex) using VBA based on column name

From Dev

Microsoft Excel - how do I copy rows from one sheet to another sheet filtered by a value

From Dev

excel - find data in one column in sheet that is not in another sheet if date is later

From Dev

Copy comments from one excel sheet to another with Apache POI

From Dev

How to copy a sheet to another in php laravel excel?

From Dev

VBA Copy data from one sheet to another

From Dev

How do I copy a csv Sheet into an excel file without changes

From Dev

Excel - How to auto-populate from one sheet to another

From Dev

Description from one sheet into comment of another sheet in Excel

From Dev

How to copy only formulas from one excel sheet which can dynamically grow to another sheet using macro

From Dev

Need a script to transfer data from one excel sheet to another

From Dev

How can I copy a column from one sheet to another sheet based on title in Excel?

From Dev

Extracting data from an excel sheet into another excel sheet

From Dev

Copy data from one excel sheet to another (complex) using VBA based on column name

From Dev

Unable to copy data from one Excel sheet to another when not copying to column A

From Dev

Show data from one sheet into another (Excel 15, Mac)

From Dev

Sync data from one Excel Sheet to another

From Dev

Copy multiple data columns with the same key from another sheet excel

From Dev

Excel to copy / paste some cells from one sheet to another but with a twist

From Dev

I am trying to get excel to pull data from one sheet and list it on another sheet if certain criteria are met

From Dev

Copy two columns from one Excel sheet to another

From Dev

Excel - Copy data from multiple sheets to one sheet

From Dev

copy data from one sheet and past it on another sheet of same workbook

From Dev

Copying excel row from one sheet to another

From Dev

Need to copy range of data from one excel sheet to another based on first coulmn value

From Dev

Excel copy data from one sheet to another based on a condition

From Dev

VBA - Copy data from one sheet to another

From Dev

How to store and update data from one excel interface (Sheet 1) to another sheet (Sheet 2) to keep track on the transaction history?

Related Related

  1. 1

    How to copy only formulas from one excel sheet which can dynamically grow to another sheet using macro

  2. 2

    Copy data from one excel sheet to another (complex) using VBA based on column name

  3. 3

    Microsoft Excel - how do I copy rows from one sheet to another sheet filtered by a value

  4. 4

    excel - find data in one column in sheet that is not in another sheet if date is later

  5. 5

    Copy comments from one excel sheet to another with Apache POI

  6. 6

    How to copy a sheet to another in php laravel excel?

  7. 7

    VBA Copy data from one sheet to another

  8. 8

    How do I copy a csv Sheet into an excel file without changes

  9. 9

    Excel - How to auto-populate from one sheet to another

  10. 10

    Description from one sheet into comment of another sheet in Excel

  11. 11

    How to copy only formulas from one excel sheet which can dynamically grow to another sheet using macro

  12. 12

    Need a script to transfer data from one excel sheet to another

  13. 13

    How can I copy a column from one sheet to another sheet based on title in Excel?

  14. 14

    Extracting data from an excel sheet into another excel sheet

  15. 15

    Copy data from one excel sheet to another (complex) using VBA based on column name

  16. 16

    Unable to copy data from one Excel sheet to another when not copying to column A

  17. 17

    Show data from one sheet into another (Excel 15, Mac)

  18. 18

    Sync data from one Excel Sheet to another

  19. 19

    Copy multiple data columns with the same key from another sheet excel

  20. 20

    Excel to copy / paste some cells from one sheet to another but with a twist

  21. 21

    I am trying to get excel to pull data from one sheet and list it on another sheet if certain criteria are met

  22. 22

    Copy two columns from one Excel sheet to another

  23. 23

    Excel - Copy data from multiple sheets to one sheet

  24. 24

    copy data from one sheet and past it on another sheet of same workbook

  25. 25

    Copying excel row from one sheet to another

  26. 26

    Need to copy range of data from one excel sheet to another based on first coulmn value

  27. 27

    Excel copy data from one sheet to another based on a condition

  28. 28

    VBA - Copy data from one sheet to another

  29. 29

    How to store and update data from one excel interface (Sheet 1) to another sheet (Sheet 2) to keep track on the transaction history?

HotTag

Archive