kctvt Posted June 30, 2022 Posted June 30, 2022 How to Copy All Data from column A (Excel2) to column C (Excel1) Global $oExcel = _Excel_Open(True) Global $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls") Global $oExcel2 = _Excel_Open(True) Global $oWorkbook2 = _Excel_BookOpen($oExcel2, @ScriptDir & "\Extras\_Excel2.xls") Local $oRange = $oWorkbook2.Worksheets(1).Range("A") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange, "C")
Subz Posted July 1, 2022 Posted July 1, 2022 (edited) A few different ways: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls") Global $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel2.xls") ;~ Option 1 - Using ActiveSheet Local $oRange1 = $oWorkbook1.ActiveSheet.Columns("A") Local $oRange2 = $oWorkbook2.ActiveSheet.Columns("C") _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange1, $oRange2) ;~ Option 2 - Using Worksheet index Local $oRange1 = $oWorkbook1.Worksheets(1).Columns("A") Local $oRange2 = $oWorkbook2.Worksheets(1).Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2) ;~ Option 3 - Using Worksheet name Local $oRange1 = $oWorkbook1.Worksheets("Sheet1").Columns("A") Local $oRange2 = $oWorkbook2.Worksheets("Sheet1").Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2) Edited July 1, 2022 by Subz kctvt 1
kctvt Posted July 1, 2022 Author Posted July 1, 2022 3 hours ago, Subz said: A few different ways: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls") Global $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel2.xls") ;~ Option 1 - Using ActiveSheet Local $oRange1 = $oWorkbook1.ActiveSheet.Columns("A") Local $oRange2 = $oWorkbook2.ActiveSheet.Columns("C") _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange1, $oRange2) ;~ Option 2 - Using Worksheet index Local $oRange1 = $oWorkbook1.Worksheets(1).Columns("A") Local $oRange2 = $oWorkbook2.Worksheets(1).Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2) ;~ Option 3 - Using Worksheet name Local $oRange1 = $oWorkbook1.Worksheets("Sheet1").Columns("A") Local $oRange2 = $oWorkbook2.Worksheets("Sheet1").Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2) Thank you Subz, I try Local $oRange1 = $oWorkbook1.ActiveSheet.Columns("A:Z") Local $oRange2 = $oWorkbook2.ActiveSheet.Columns("A:Z") _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange1, $oRange2) I worked
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now