LandoMarossi
Programmer
Hi,
I'm trying to copy specific column values (range "M") from one excel 365 file to the other on the range "M", using VBScript.
Master.xlsx file structure
Copy_2022.xlsx file structure (after the copy columns from Master.xlsx)
The copy of specific column values working correctly from Master.xlsx file to Copy_2022.xlsx file.
But the problem is that the copied columns values start from cell M1 and not from cell M4 on Copy_2022.xlsx file.
This is what I've tried.
Any suggestion?
I'm trying to copy specific column values (range "M") from one excel 365 file to the other on the range "M", using VBScript.
Master.xlsx file structure
Copy_2022.xlsx file structure (after the copy columns from Master.xlsx)
The copy of specific column values working correctly from Master.xlsx file to Copy_2022.xlsx file.
But the problem is that the copied columns values start from cell M1 and not from cell M4 on Copy_2022.xlsx file.
This is what I've tried.
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\Master.xlsx")
Set objWorkbook2 = objExcel.Workbooks.Open("C:\Copy_2022.xlsx")
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate
objWorkbook2.Worksheets(1).UnProtect
Set objRange = objWorkSheet.Range("M:P").EntireColumn
objRange.Copy
Set objWorksheet2 = objWorkbook2.Worksheets(1)
objWorksheet.Activate
Set objRange = objWorkSheet2.Range("M:P")
objWorksheet.Paste(objRange)
objWorkbook2.Save
objWorkbook2.Close
objWorkbook.Close
objExcel.Quit
Set objExcel = Nothing
Any suggestion?