I have multiple excel files in a same folder which contains data in sheet1. I wanted to copy paste data all the excel files into 1 excel file "Macro.xlsx". The code is like it copies data from Rahul.xlsx to Macro.xlsx and then from Rohit.xlsx to Macro.xlsx and so on. The problem is that while pasting data from Rohit.xlsx it ios overlaping. The code is not finding the next available blank row to paste data and this is due to code [Sheets("Sheet1").Range("A1").Select]. Can someone help me edit the code.
Code:
Sub OpenCopyPaste()
' open the source workbook and select the source sheet
Workbooks.Open Filename:="C:\Users\Rahul\Desktop\Test\Rahul.xlsx"
Sheets("Sheet1").Select
' copy the source range
Sheets("Sheet1").Range("A:G").Select
Selection.Copy
' select current workbook and paste the values starting at A1
Windows("Macro.xlsx").Activate
Sheets("Sheet1").Select
Sheets("Sheet1").Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode =False
ActiveWorkbook.Save
Workbooks.Open Filename:="C:\Users\Rahul\Desktop\Test\Rohit.xlsx"
Sheets("Sheet1").Select
' copy the source range
Sheets("Sheet1").Range("A:G").Select
Selection.Copy
' select current workbook and paste the values starting at A1
Windows("Macro.xls").Activate
Sheets("Sheet1").Select
Sheets("Sheet1").Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode =False
ActiveWorkbook.Save
EndSub
Last edited by a moderator: