Public Sub Main_From_SourceToTarget()
'http://www.excelforum.com/excel-programming/808336-importing-and-exporting-data-from-workbook-to-workbook-in-excel.html
On Error GoTo EH_Main_From_SourceToTarget
Dim lng As Long
Dim i As Integer
'-------------------
'-------------------
ms_SubName = "Public Sub Main_From_SourceToTarget()"
'-------------------
' This WB
'-------------------
Set mo_WBThis = ThisWorkbook
ms_WBThisVersion = Application.Version
ms_WBThisPath = ThisWorkbook.Path
'-------------------
' WB Source
'-------------------
ms_WBSourceName = "Source.xlsx" '<------- Change to real after testing this
ms_WBSourcePath = ms_WBThisPath & "C:\Documents and Settings\frances\Desktop\New Folder\Source.xlsx" '<------- Change to real after testing this
ms_WBSourceFullName = ms_WBSourcePath & ms_WBSourceName
'-------------------
' WB Target
'-------------------
ms_WBTargetName = "Target.xlsx" '<------- Change to real after testing this
ms_WBTargetPath = ms_WBThisPath & "C:\Documents and Settings\frances\Desktop\New Folder\Target.xlsx" '<------- Change to real after testing this
ms_WBTargetFullName = ms_WBTargetPath & ms_WBTargetName
'-------------------
' Check WB Source EXISTS
'-------------------
mb_Bool = IsFile(ms_WBSourceFullName)
If Not mb_Bool Then
MsgBox "File " & ms_WBSourceFullName & vbCrLf & vbCrLf & "Does not exist." & vbCrLf & vbCrLf & "Terminating ................ ", vbCritical, ms_SubName
Exit Sub
Else
'-------------------
' IGNORE
' FYI - Not Necessary but works
'-------------------
If 1 = 2 Then
Set mo_WBSource = Application.Workbooks.Open(ms_WBSourceFullName)
End If
End If
'-------------------
' Check WB Target EXISTS
'-------------------
mb_Bool = IsFile(ms_WBTargetFullName)
If Not mb_Bool Then
MsgBox "File " & ms_WBTargetFullName & vbCrLf & vbCrLf & "Does not exist." & vbCrLf & vbCrLf & "Terminating ................ ", vbCritical, ms_SubName
Exit Sub
Else
'-------------------
' FYI - Not Necessary but works
'-------------------
If 1 = 2 Then
' IGNORE
Set mo_WBTarget = Application.Workbooks.Open(ms_WBTargetFullName)
End If
Bookmarks