Question : Copy and Paste Data from different folder

Hi Experts,

I need Experts help. Currently I’m using the attached code to copy and paste data from WB1 to WB2 (within same folder). How to copy data if the workbook (WB1) resided in different location? The new location of WB1 is : "\\bc04\FileShare\PO\Services\Generic Document\OT".
Hope Experts could help me to rewrite the code.

.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Sub copy()
Application.ScreenUpdating = False
Dim wb1 As Workbook, wb2 As Workbook
Set wb2 = ActiveWorkbook
Dim loc As String, wb1Name As String
Dim wb1WasOpen As Boolean
wb1WasOpen = False
loc = ActiveWorkbook.Path & "\"
wb1Name = "Tracker_3244"
On Error Resume Next
Set wb1 = Workbooks(wb1Name)
On Error GoTo 0
If wb1 Is Nothing Then
    Set wb1 = Workbooks.Open(loc & wb1Name & ".xls")
Else
    wb1WasOpen = True
End If
wb1.Sheets("Summary").Range("B1:S66").Copy
wb2.Sheets("Expenses").Range("B1:S66").PasteSpecial xlPasteValues
If Not wb1WasOpen Then wb1.Close
Application.ScreenUpdating = True
End Sub

Answer : Copy and Paste Data from different folder

Theva

Chnage
loc = ActiveWorkbook.Path & "\"
to your actual path, ie
loc ="Z:\bc04\FileShare\PO\Services\Generic  Document\OT\"

Note I added a network drive letter, you will need to supply the actual path

Cheers

Dave


Random Solutions  
 
programming4us programming4us