yaroslav89
New Member
- Joined
- Jul 11, 2018
- Messages
- 10
Hello Everyone,
My macro is basic and all its doing is copying (specific range) and pasting that range in another file. Because there is a lot of data to copy and from many different files. It is difficult to keep track of what is copied and what is still missing. I would like to have some sort of a tracker. Maybe a loop? Basically I would like to create an additional step. If file is copied, then give me a result of a specific cell in that copied file (Let's just say A1) and keep giving me results for every file that is being copied. Ideally, I would like the result to be in the file where the rest of the data is being copied, maybe just a different tab, but immediate window is ok too. If you have any thought or ideas, I would greatly appreciate. Below is my code in its basic form.
Sub Extract_Data()
Dim x As Workbook, y As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
'x is copy data
'y is paste data
Set x = Workbooks.Open("C:\Users\Documents\Data")
Set y = Workbooks.Open("C:\Users\Documents\Final Product")
Set ws1 = x.Sheets("Sheet1")
Set ws2 = y.Sheets("Sheet1")
ws1.Cells.Range("A1:R6").Copy ws2.Range("A1")
y.Close True
x.Close False
My macro is basic and all its doing is copying (specific range) and pasting that range in another file. Because there is a lot of data to copy and from many different files. It is difficult to keep track of what is copied and what is still missing. I would like to have some sort of a tracker. Maybe a loop? Basically I would like to create an additional step. If file is copied, then give me a result of a specific cell in that copied file (Let's just say A1) and keep giving me results for every file that is being copied. Ideally, I would like the result to be in the file where the rest of the data is being copied, maybe just a different tab, but immediate window is ok too. If you have any thought or ideas, I would greatly appreciate. Below is my code in its basic form.
Sub Extract_Data()
Dim x As Workbook, y As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
'x is copy data
'y is paste data
Set x = Workbooks.Open("C:\Users\Documents\Data")
Set y = Workbooks.Open("C:\Users\Documents\Final Product")
Set ws1 = x.Sheets("Sheet1")
Set ws2 = y.Sheets("Sheet1")
ws1.Cells.Range("A1:R6").Copy ws2.Range("A1")
y.Close True
x.Close False