Dim xlsPath As String
xlsPath = "C:\"
Workbooks(xlsPath & "Output.xls").Sheets("Output").Range("B2:B6").Copy
I am trying above code for this but getting error.
Dim xlsPath As String
xlsPath = "C:\"
Workbooks(xlsPath & "Output.xls").Sheets("Output").Range("B2:B6").Copy
I am trying above code for this but getting error.
In order to reference the Workbook xlsPath & "Output.xls", it needs to already be opened in Excel. This is explained in the Workbook Object definition here.
... the workbook must already be open in Microsoft Excel.
What you probably want to do is use the ExecuteExcel4Macro function as was previously answered here.
Resolved -- I tried below code to access data without opening another excel.
`Application.ScreenUpdating = False Workbooks.Open Filename:="C:\Output.xls" Workbooks("Input.xls").Worksheets("abc").Activate
Workbooks("Output.xls").Close SaveChanges:=False`