Last active
August 29, 2015 14:21
-
-
Save aaira-a/4df8a3df9205cceafcb1 to your computer and use it in GitHub Desktop.
xls vba script to copy multiple columns to other workbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub CopyColumnsToOtherWorkbook() | |
Dim srcBook As Workbook | |
Dim srcSheet As Worksheet | |
Dim destSheet As Worksheet | |
Set srcBook = Workbooks.Open("C:\vba\source.xlsm", ReadOnly = True) | |
Set srcSheet = srcBook.Worksheets("SheetName") | |
Set destSheet = ThisWorkbook.Worksheets("SheetName") | |
srcSheet.Range("H2:H4").Copy | |
destSheet.Range("D3:D5").PasteSpecial (xlPasteValues) | |
srcSheet.Range("T2:T4").Copy | |
destSheet.Range("H3:H5").PasteSpecial (xlPasteValues) | |
srcBook.Close | |
ThisWorkbook.Save | |
ThisWorkbook.Close | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment