Saturday, 9 February 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 Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts