![]() |
Use one Macro on multiple workbooks
I have a number of workbooks, each containing a database with identical sheet
layouts. I want to use a single macro to copy a group of formulas from one workbook (Formulas.xls) that will copy to and then run against any of the databases (ex. 090918.xls). I have written a macro that works (test 4), but it only works on one database. Is there a way to have the macro select ActiveWorkbook instead of the specific workbook I used when I wrote the macro? See underlined example below: ' Test4 Macro ' Macro recorded 3/9/2009 by Ralph Forbes ' ' Keyboard Shortcut: Ctrl+z ' Windows("Formulas.XLS").Activate Range("L15:Q17").Select Selection.Copy Windows("090918.xls").Activate ActiveSheet.Paste Range("L17:Q17").Select Application.CutCopyMode = False Thank you, Ralph Forbes |
Use one Macro on multiple workbooks
Something like:
Dim ws as Worksheet set ws = activeworkbook Windows("Formulas.XLS").Range("L15:Q17").Copy ws.range("L15:q17").paste Should work - I've free typed that so you may have to tweak the syntax. "RSForbes" wrote: I have a number of workbooks, each containing a database with identical sheet layouts. I want to use a single macro to copy a group of formulas from one workbook (Formulas.xls) that will copy to and then run against any of the databases (ex. 090918.xls). I have written a macro that works (test 4), but it only works on one database. Is there a way to have the macro select ActiveWorkbook instead of the specific workbook I used when I wrote the macro? See underlined example below: ' Test4 Macro ' Macro recorded 3/9/2009 by Ralph Forbes ' ' Keyboard Shortcut: Ctrl+z ' Windows("Formulas.XLS").Activate Range("L15:Q17").Select Selection.Copy Windows("090918.xls").Activate ActiveSheet.Paste Range("L17:Q17").Select Application.CutCopyMode = False Thank you, Ralph Forbes |
Use one Macro on multiple workbooks
With Workbooks("Formulas.XLS")
.Range("L15:Q17").Copy Activeworkbook.ActiveSheet.Range("L17:Q17").Paste End With -- __________________________________ HTH Bob "RSForbes" wrote in message ... I have a number of workbooks, each containing a database with identical sheet layouts. I want to use a single macro to copy a group of formulas from one workbook (Formulas.xls) that will copy to and then run against any of the databases (ex. 090918.xls). I have written a macro that works (test 4), but it only works on one database. Is there a way to have the macro select "ActiveWorkbook" instead of the specific workbook I used when I wrote the macro? See underlined example below: ' Test4 Macro ' Macro recorded 3/9/2009 by Ralph Forbes ' ' Keyboard Shortcut: Ctrl+z ' Windows("Formulas.XLS").Activate Range("L15:Q17").Select Selection.Copy Windows("090918.xls").Activate ActiveSheet.Paste Range("L17:Q17").Select Application.CutCopyMode = False Thank you, Ralph Forbes |
All times are GMT +1. The time now is 01:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com