Saturday, February 9, 2013

How to Import and Export Data between This Workbook and Target Workbook

Excel VBA Macro To Export Data From My Sheet of This Workbook To Target Sheet of Target Workbook
Sub ExportToTarget()
On Error GoTo Error:
Application.DisplayAlerts = False
ThisWorkbook.Sheets("MySheet").Cells.Copy

Workbooks.Open "C:\Documents and Settings\Administrator\My Documents\Target"
ActiveWorkbook.Sheets("TargetSheet").Range("A1").Select

ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close

Exit Sub


Error:
MsgBox Err.Description
End Sub
------------------------------------------------------------------------------------------------
Macro To Import Data From Target Sheet of Target Workbook to My Sheet of This Workbook

Sub ImportDataFromTarget()
On Error GoTo Error:
Application.DisplayAlerts = False

Workbooks.Open "C:\Documents and Settings\Administrator\My Documents\Target"
ActiveWorkbook.Sheets("TargetSheet").Cells.Copy

ThisWorkbook.Sheets("MySheet").Activate
ActiveSheet.Range("A1").Select
ActiveSheet.Paste

Workbooks("Target").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

Exit Sub

Error:
MsgBox Err.Description

End Sub


Thanks, TAMATAM

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.