Hi,
I was wondering if you can help. I'am trying to open two excel files and copy cells from one to another. The files are opening but I'am getting a "Subscript out of range" when I try to copy the cells. From reading up on this, it seems that I need to break down the code further to a more readable format. Any suggestions so I can avoid the problem? . Thanks - Rpax
I was wondering if you can help. I'am trying to open two excel files and copy cells from one to another. The files are opening but I'am getting a "Subscript out of range" when I try to copy the cells. From reading up on this, it seems that I need to break down the code further to a more readable format. Any suggestions so I can avoid the problem? . Thanks - Rpax
VBA Code:
MyDateFormat = Year(now) & Right("0" & Month(Now), 2) & Right("0" & Day(now), 2)
Set Excel = CreateObject("Excel.Application")
Set ExcelNew = CreateObject("Excel.Application")
ExcelNew.Application.DisplayAlerts = False
ExcelNew.Application.Visible = True
ExcelNew.Workbooks.Open("C:\Program Files\Tank_Reports\Solvents"& ".xls")
Excel.Application.DisplayAlerts = False
Excel.Application.Visible = True
Excel.Workbooks.Open("C:\Program Files\Tanks.xls")
wscript.sleep(5000)
[B]Excel.Workbooks("C:\Program Files\Tanks.xls").Worksheets("Sheet1").Range("A1:C27").Copy
ExcelNew.Workbooks("C:\Program Files\Tank_Reports\Solvents"& ".xls").Worksheets("Sheet1").Range("A1")[/B]
ExcelNew.Activeworkbook.SaveAs "C:\Program Files\Tank_Reports\Solvents_" & MyDateFormat & ".xls"
Excel.Activeworkbook.Close
ExcelNew.Activeworkbook.Close
Excel.Quit
WScript.Quit