0% found this document useful (0 votes)
11 views

ASBA2(3)

The document contains a VBA macro named 'ExportData' that automates the process of copying a specified range of data from a source Excel workbook to a destination workbook. It opens the source workbook, copies data from a defined range in a specified sheet, and pastes it into a designated sheet of the destination workbook. After completing the data transfer, it closes the source workbook without saving changes and displays a message indicating the completion of the export.

Uploaded by

asarudeenahamed4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

ASBA2(3)

The document contains a VBA macro named 'ExportData' that automates the process of copying a specified range of data from a source Excel workbook to a destination workbook. It opens the source workbook, copies data from a defined range in a specified sheet, and pastes it into a designated sheet of the destination workbook. After completing the data transfer, it closes the source workbook without saving changes and displays a message indicating the completion of the export.

Uploaded by

asarudeenahamed4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub ExportData()

Dim srcWorkbook As Workbook


Dim destWorkbook As Workbook
Dim srcSheet As Worksheet
Dim destSheet As Worksheet
Dim srcRange As Range
' Open the source workbook
Set srcWorkbook = Workbooks.Open("C:\Path\To\Source\File.xlsx")
' Set the source worksheet and range
Set srcSheet = srcWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your actual sheet name
Set srcRange = srcSheet.Range("A1:D10") ' Adjust the range as needed
' Open the destination workbook
Set destWorkbook = ThisWorkbook ' Use ThisWorkbook if running the macro from the
destination file
' Set the destination worksheet
Set destSheet = destWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your actual destination
sheet name

' Copy data from source to destination


srcRange.Copy destSheet.Range("A1") ' Adjust the starting cell as needed
' Close the source workbook without saving changes
srcWorkbook.Close SaveChanges:=False
MsgBox "Data export complete!"
End Sub
Run the Macro:
o your actual sheet name

t; to your actual destination

You might also like