Rex
asked on
how Do I get VBA to act on whatever Excel file i have open as the Object?
I used Excel to Record to get a start
But I get a "subscript out of range" error
I need the object to be whatever Excel file i have open, as the name changes, but the sheets and range locations are always the same.
I am trying to get the macro to extract that one cell (N61) data and copy/paste it into the next available cell in a column in another Workbook, where i am trying to create a linked table for Access.
ActiveWindow.ScrollWorkbookTabs Sheets:=-15
Sheets("Production Summary").Select
ActiveWindow.SmallScroll Down:=21
Range("N61").Select
Selection.Copy
Windows("Prodsumm_tbl.xlsx").Activate
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
ActiveWindow.LargeScroll Down:=1
Range("B65").Select
ActiveWindow.LargeScroll Down:=1
Range("B99").Select
But I get a "subscript out of range" error
I need the object to be whatever Excel file i have open, as the name changes, but the sheets and range locations are always the same.
I am trying to get the macro to extract that one cell (N61) data and copy/paste it into the next available cell in a column in another Workbook, where i am trying to create a linked table for Access.
ActiveWindow.ScrollWorkbookTabs Sheets:=-15
Sheets("Production Summary").Select
ActiveWindow.SmallScroll Down:=21
Range("N61").Select
Selection.Copy
Windows("Prodsumm_tbl.xlsx").Activate
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
ActiveWindow.LargeScroll Down:=1
Range("B65").Select
ActiveWindow.LargeScroll Down:=1
Range("B99").Select
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ActiverWorkbook and ActiveSheet can be used to refer to the currently active workbook and worksheet.
»bp
»bp
Oops, didn't notice the Copy.
ASKER
Thank you all very much
ActiveWorkBook will always refer to the workbook that is active.
If Sheets("Production Summary") is in the workbookwith the code then assuming that the destination sheet is open in the destination workbook it could be
Open in new window